需要做'',工作

时间:2015-10-26 14:41:13

标签: python

file = open("SampleList.txt", "r")
x = file.readlines()
y = []
for i in range (len(x)):
    print x[i].split()

这是我的代码,这是输出

['100000,Weasely', ',Bill', ',9,1', 'Discipline,0']
['120001,Weasely', ',Fred', ',10,1', 'Discipline,0']
['120002,Weasley', ',George', ',6,1', 'Tardies,0']
['130003,Weasley', ',Ronald', ',10,OK,0']
['130004,Longbottom', ',Neville', ',5,1', 'Absence,0']
['130005,Potter', ',Harry', ',5,OK,0']
['130006,MAlfoy', ',Draco', ',5,1', 'Owes', 'more', 'than', '$5,$150.00']    
['100118,The', 'House', 'Elf', ',Dobbey', ',7,OK,0']
['100011,LaStrange', ',Belatrix', ',8,1', 'Discipline,0']
['100170,Dumbledore', ',Albus', ',7,1', 'Administration,0']
>>> 

我需要的是['数字','姓氏','名字'等等]

1 个答案:

答案 0 :(得分:3)

您可以将文件转换为.csv格式并说出

D:\Study\Java>java FutureDemo
Result:0
Result:1
Result:2
Result:3
Result:4
Result:5
Result:6
Result:7
Result:8
Result:9
-

可能?