我有以下代碼。每次我運行此我得到的錯誤TypeError:'int'object is not iterble
TypeError: 'int' object is not iterable for the '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)
'對於我在Number:','Number'是'int'。你可能想'append'而不是set('=')'Number' ... –
將Number =(int(j))更改爲'Number.append(int(j))' –
No change Number =(int(j))''Number.append(int(j))'... –