使用DataFrame python将控制台输出写入excel工作表
for foo in root.finadall(xpath):
print (foo.name[xpath], foo.country[xpath])
df = DataFrame({'Name': foo.name[xpath], 'conutry': foo.country[xpath]})
df.to_excel('foo.xlsx', sheet_name='sheet1', index=False)
输出将打印控制台中的大量名称。但在excel中,它只存储最小的一个。如何在excel中存储所有名称。
要获得清晰的想法:
The console output:
Name Country
jennfier abc
andy john cde
carwl xyz
在excel中,我看到了唯一的carwl xyz。
转载请注明出处:http://www.xinxianzhihui.com/article/20230526/2057984.html