'str' object has no attribute 'readlines' 错误解析 1. 错误含义 'str' object has no attribute 'readlines' 错误表明你尝试在一个字符串(str)对象上调用 readlines() 方法,但字符串类型并没有这个方法。readlines() 是文件对象(如通过 open() 函数打开的文件)的方法,用于读取文件中的所有行并返回一个包含...
主要错误是1.语法错误,如以上朋友回答。2. 不能print(data),因为他是一个_io.TextIOWrapper 3.如果为了显示每一行,用readline才好。正确代码如下:data =open(r'C:\Users\Administrator\Desktop\dd.txt',encoding='utf-8',errors='ignore')while True:each_line=data.readline()print(each_line...
你这里的file_ob_list 只是文件路径字符串的列表, 在最后你for循环迭代出来应该需要使用open来打开它 for file_ob in file_ob_list:with open(file_ob, "r") as fp:lines = fp.readlines()
根据报错我猜是html这个变量被一个字符串覆盖了。建议检查一下代码或者把出错的代码贴出来。