-1
該程序運行在一個循環中,併爲信息列表中列出的記錄數生成文件。但是對於該列表中的最後一條記錄,它將生成一個空白文件。 final_list永遠不是空白的,我檢查,但仍然每次最後一個正在創建的文件是空的。有人可以告訴我做錯了嗎?由程序創建的空白文件
outputC = net_connect.send_command("show int desc | i xe")
outputC1 = net_connect.send_command("show int desc | i xt")
final_list = capture_op(outputC,outputC1)
length = len(info[count][1])
name = info[count][1]
name = name[0:length]+".txt"
for path,dirname,filename in os.walk("."):
for file in filename:
if file == name:
os.remove(name)
break
fo=open(name , 'w')
for i in final_list:
print (i)
fo.write(i)
fo.write('\n')
fo.close
count+=1
你不是叫'fo.close'。 這樣的電話: 'fo.close()' –
謝謝,即時通訊同樣的錯誤很多.. –
使用開放(...)作爲...:'你不用擔心。 – DeepSpace