关于python读取文件的问题
程序代码:
with open("C:/Users/Lenovo/Desktop/t.txt","r") as f: lines = f.read().split("\n") cons = [lines[i:i+4] for i in range(0, len(lines)-3), 2] result = [j for j in cons if 'none' not in j] print(result) f.close()
我的程序运行中出现如下的问题,
Traceback (most recent call last):
File "D:/pycharm/dd/hello.py", line 3, in <module>
cons = [lines[i:i+4] for i in range(0, len(lines)-3), 2]
TypeError: can only concatenate list (not "int") to list
请问大家可以怎么解决?谢谢。
[此贴子已经被作者于2018-5-31 13:24编辑过]