with open('list.txt') as f:
print " ".join(line.strip() for line in f)
Though the code seems to be correct, but facing syntax error !
答案 0 :(得分:1)
在python 3中,print是一个函数。见这里:https://docs.python.org/3/whatsnew/3.0.html#print-is-a-function
尝试:
with open('list.txt') as f:
print(" ".join(line.strip() for line in f))
答案 1 :(得分:0)
您正在使用python版本3,使用此
with open('line.txt') as f:
print(" ".join(line.strip() for line in f))