2014-10-27 34 views

回答

1
answer = [] 
with open('path/to/file') as infile: 
    for line in infile: 
     answer.append(line.partition('=')[0].strip()) 
+1

和'str.partition()'是快於有限的'str.split()'... – 2014-10-27 16:34:14

+0

感謝您的快速響應 – bobd 2014-10-27 16:46:49

相關問題