'''
When you first read the contents of a file , Can't succeed .
Problems arise : Failed to read when the text content is Chinese , English and figures are successful .
Solution : stay open(), Add in "r",encoding='utf-8'
The specific reason ->https://blog.csdn.net/weixin_46709219/article/details/112060945
'''
# encoding='utf-8'
# f = open(' Corn poppy .txt',"r",encoding='utf-8')
# text = f.read()
# print(text)
# f.close()
# The following code also has problems at the beginning :
# stay python in '\' Will be used as escape characters ,'C:\Users\86151\Desktop\ Corn poppy · When is the spring flowers and autumn moon .txt'
# Solution : Add before the above code ‘r’, In this way, it can be read successfully
# The specific reason ->https://www.cnblogs.com/rychh/p/9743864.html
# f = open(r'C:\Users\86151\Desktop\ Corn poppy · When is the spring flowers and autumn moon .txt',encoding='utf-8')
# for line in f:
# if (len(line.strip())==0):continue
# print(line.strip())
# f.close()
f = open(r'C:\Users\86151\Desktop\ Corn poppy · When is the spring flowers and autumn moon .txt',encoding='utf-8')
lines=f.readlines()
print(lines)
f.close()Text file reading / Write operations · Language sparrow (yuque.com)
Hee , I haven't studied for a long time
Indulge in the king Rong Yao
Feel happy , Is very empty . As time goes on, tut ...
Still have to learn a little , Come on, big pineapple