python汉字编码错误_python文件以错误的编码utf8加载

我对编程相当陌生,我不理解我得到的这个错误消息,file was loaded in the wrong encoding utf-8或者它不是代码中的错误消息,但是我在我的新的.txt文件中得到了它,我在其中写入了所有找到的关键字。txt文件将upp到4000多行,其中包含我在另一个程序中对Excel进行排序,然后将其发送到Access。这个信息是什么意思?有没有办法解决它?谢谢

我用pycharm和Python36

bG46D.pngimport 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:\Users\Documents\Access\\GTX797\*.log'):

LogFile(filename, 'Sending Request: Tester')

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值