概述
我对编程相当陌生,我不理解我得到的这个错误消息,file was loaded in the wrong encoding utf-8或者它不是代码中的错误消息,但是我在我的新的.txt文件中得到了它,我在其中写入了所有找到的关键字。txt文件将upp到4000多行,其中包含我在另一个程序中对Excel进行排序,然后将其发送到Access。这个信息是什么意思?有没有办法解决它?谢谢
我用pycharm和Python36
import glob
def LogFile(filename, tester):
data = []
with open(filename) as filesearch: # open search file
filesearch = filesearch.readlines() # read file
file = filename[37:]
for line in filesearch:
if tester in line: # extract "Create Time"
short = line[30:]
data.append(short) # store all found wors in array
print (file)
with open('Msg.txt', 'a') as handler: # create .txt file
for i in range(len(data)):
handler.write(f"{file}|{data[i]}")
# open with 'w' to "reset" the file.
with open('LogFile.txt', 'w') as file_handler:
pass
# ---------------------------------------------------------------------------------
for filename in glob.glob(r'C:UsersDocumentsAccess\GTX797*.log'):
LogFile(filename, 'Sending Request: Tester')
最后
以上就是细心航空为你收集整理的python汉字编码错误_python文件以错误的编码utf8加载的全部内容,希望文章能够帮你解决python汉字编码错误_python文件以错误的编码utf8加载所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复