【发布时间】:2019-04-13 14:03:13
【问题描述】:
我要转换的文本文件包含例如:
Alex
Gheith
40
John
Stewart
33
进入:
[('Alex','Gheith','40'),('John','Stewart','33')]
当前代码:
records =[]
f10 = open("PlayerRecords.txt","r")
for line in f10:
line = line.strip()
records.append(line)
t = ()
f10.close()
t = [(x,) for x in records]
print t
当前输出:
[('Alex','Gheith',40),('John','Stewart',33)]
【问题讨论】:
标签: python-2.7 file tuples