【发布时间】:2015-09-24 22:11:06
【问题描述】:
我制作了一个简单的程序来读取一个包含 3 行文本的文件。我已经拆分了行并从 t2 变量中获取了输出。如何去掉括号使其成为一个列表?
fname = 'dogD.txt'
fh = open(fname)
for line in fh:
t2 = line.strip()
t2 = t2.split()
print t2
['Here', 'is', 'a', 'big', 'brown', 'dog']
['It', 'is', 'the', 'brownest', 'dog', 'you', 'have', 'ever', 'seen']
['Always', 'wanting', 'to', 'run', 'around', 'the', 'yard']
【问题讨论】:
标签: python