|
本帖最后由 syhin 于 2018-5-31 09:31 编辑
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
|
|