我有以下代码。每次我运行这个我都会收到错误
TypeError:'int'对象不能为'Number'迭代。
f = open("E:\\vivek.txt","r")
waitstate = 0
Number = []
l_ines = []
l_ines=f.readlines()
#print(l_ines)
for i in l_ines:
if len(i.split("# Waits"))>1:
elements = []
elements = ((i.split("# Waits")[1]).split(" "))
for j in elements:
if j!="":
try:
Number = (int (j))
#Number = j
#print(Number)
except:
pass
for i in Number:
print(i)
答案 0 :(得分:0)
替换
var intToReturn:Int = 0 or
var intToReturn = 0
使用
Number = (int (j))
因为您已将Number定义为列表,所以您无法将其更改为整数,您需要将整数附加到列表中。