Python文件操作相关方法
File I/O
open(path, falg[,encoding],[errors])
flag:打开方式
r - read only
rb - open file in bite and read only
r+ - open a file and can read and write
w - open a file and write only
wb - write only in bite
w+ -- write and read
a -- append content in a opened file
#windows的path要将\转成/如果前面不加r
#path = 'C:/Users/qiuy/PycharmProjects/pythonProject/file.txt'
#加r后path要用双引号
#path = r"C:\Users\qiuy\PycharmProjects\pythonProject\file.txt"
#try:
#f = open(path,'r')
#修改文件描述符的位置,从第x个字节开始操作
#f.seek(10)
#1.read all the content of the file
#file_all = f.read()
#read的参数是字节数
#file_part = f.read(100)
#print(file_part)
#2.read part of the file
#file_line = f.readline()
#print('readline',file_line)
#file_lines = f.readlines()
#print('readlines',file_lines)
#write into a file
# f = open(path,&#