‘‘‘
Unicodedecodeerror: ' GBK ' codec can ' t decode byte 0x80 in position 106:illegal multibyte sequence
Encoding= "Utf-8"
Windows defaults to using the GBK
‘‘‘
#data =open ("Chaochao", encoding= "Utf-8"). Read ()
‘‘‘
F=open ("Chaochao", ' R ', encoding= "Utf-8") #赋值给f文件句柄: Contains the file name, character set, size, and in-memory location read-only
D=open ("Chaochao", ' W ', encoding= "Utf-8") #赋值给f文件句柄: Contains the file name, character set, size, and location in memory only new write (overwrite)
E=open ("Baobao", ' a ', encoding= "Utf-8") #赋值给f文件句柄: Contains the file name, character set, size, and location appended in memory
Data=f.read ()
Data2=f.read ()
Print (data)
Print ("------------>data-------------------------------------------------%s-------"%data2)
Print (data)
D.write ("I love Beijing Tian ' an door, I love baby, \ n")
E.write ("Henan people in Shanghai")
F.close ()
D.close ()
E.close ()
‘‘‘
# #high
# F=open ("Chaochao", ' R ', encoding= "Utf-8")
# count=0
# i=0
# Print (F.tell ()) # Tell by character Count
# F.seek (140)
# Print (F.readline ())
# Print (F.tell ()) # Tell by character Count
# Print (F.readline ())
# Print (F.tell ()) # Tell by character Count
# print (f.encoding) #打印文件编码
# Print (F.fileno ()) #返回句柄在文件系统中的编号
# # # # # # # *able is the ability to determine if the function can be manipulated
# Print (F.flush ()) #默认缓存达到指定大小写入内存 Force write memory
#
# for line in F: #打印内存是保存一行 convert Text to counter
# if count==9:
# i + = 1
# continue
#
# Print (I,line.strip ())
# count + = 1
#low Loop
‘‘‘
F=open ("Chaochao", ' R ', encoding= "Utf-8")
#for line in F.readlines ():
For Index,line in Enumerate (F.readlines ()):
If index = = 9: #跳打第十行
Print ("---------------I am Split Line--------------------")
Continue
Print (Line.strip ()) #strip is to remove line breaks, and spaces
# for I in range (5):
# Print (F.readline ())
‘‘‘
#f =open ("Chaochao", ' r+ ', encoding= "Utf-8") #追加方式打开 Read and write
#f =open ("Chaochao", ' w+ ', encoding= "Utf-8") #追加方式打开 Read and write
# F=open ("Chaochao", ' RB ') #以二进制形式打开
#
# Print (F.readline ())
# Print (F.readline ())
# Print (F.readline ())
# print ("-----------------------------------Woshifengexian-------------")
# Print (F.readline ())
# Print (F.tell ()) #打印光标
# #f. Write ("Heheheheehehehehehehehehehehe--------------------------------")
# Print (F.readline ())
#
# F=open ("Chaochao", ' R ', encoding= "Utf-8")
# F_new=open ("chaochao11111", "', encoding=" Utf-8 ")
#
# for line in F:
# if "Hehhehehe" ==line:
# line = Line.replace ("Hehhehehe", "Woshi Wanyachao")
# F_new.write (line)
# F.close ()
# Print (f_new)
# F_new.close ()
# with open ("Chaochao", ' R ', encoding= "Utf-8") as f,\ multiple files can be opened simultaneously
# Open ("Chaochao", ' R ', encoding= "Utf-8") as D:
# for line in F:
# if
#
Python Basics-File manipulation