Part IV – Input/Output Files การอา่ นและเขียนไฟล์ #Example 1 file = open(\"d:/newfile.txt\", \"w\") # file.write(\"hello world in the new file\") file.write(\"and another line\") file.close() file = open(\"d:/newfile.txt\", \"r\") print(file.read()) file.close() file = open(\"d:/newfile.txt\", \"r\") print(file.read(5)) #using file.read(n), where \"n\" determines number of characters. file.close()
Part IV – Input/Output Files การอ่านและเขยี นไฟล์ #Example 1 file = open(\"d:/newfile.txt\", \"r\") print(file.readline()) file.close()''' file = open(\"d:/newfile.txt\", \"r\") for line in file: print(line)
อา้ งงอิง https://www.google.com/search?q=python&oq=python&aqs=chrome ..
Search