标签:原因 exti for循环 一个 for 方法 http tee bing
Python 错误!AttributeError: ‘_io.TextIOWrapper‘ object has no attribute ‘xreadlines‘
Traceback (most recent call last):
File "countline.py", line 33, in <module>
totalline = totalline + countLine(filelist)
File "countline.py", line 23, in countLine
for file_line in open(fname).xreadlines():
AttributeError: ‘_io.TextIOWrapper‘ object has no attribute ‘xreadlines‘
原因:
解决方法:
for file_line in open(fname).xreadlines():
改为:for file_line in open(fname, encoding="utf-8").readlines():
加上utf-8就不会乱码了。
?
文章来源:刘俊涛的博客 欢迎关注公众号、留言、评论,一起学习。
?
若有帮助到您,欢迎点击推荐,您的支持是对我坚持最好的肯定(*^_^*)
AttributeError: ‘_io.TextIOWrapper‘ object has no attribute ‘xreadlines‘
标签:原因 exti for循环 一个 for 方法 http tee bing
原文地址:https://www.cnblogs.com/lovebing/p/13048948.html