Python的一些应用 jupyter notebook源码
总体思想:将列表变为dataframe再进行转存。
代码:
import pandas as pd
# 假设有列表a
a = ['An attemped build of gfortran from a fresh', 'With a new download of gfortran the build now fails', 'While bootstrapping I noticed.checking for compiler with P', 'define weakexternexpr Pragma expr.', 'Reading the documention at url console objdir', 'The 20051227 version of gfortran has 144 new', 'Volker Reichelt reicheltigpm.', 'javax.security.auth. loginException no configured', 'I was going to do a enablecheckingrelease buil to', 'Allrecursive Error 1.make2 all Error 2', 'libjava fails to build in a cross compiler using newlib', 'Gcc cannot process inlined assembler when configured for power', 'The following testcase..extern int f1 void .', 'The compiler builds but when it tries to build libgcc', 'Gcc 4.2 miscompiles binutils on Linux', 'I just tried to compile Suse package gnomeprint0']
# 将list转为dataframe 显然就变成一列了
d = pd.DataFrame(a)
d.to_csv('a.csv',index=False,mode='a',header=None) # mode表示追加 在追加时会将列名也作为一行进行追加,故header隐藏表头(列名)