我正在使用python 2.6.6 蟒
Python 2.6.6 (r266:84292, Aug 18 2016, 15:13:37)
下面是script.py文件,我在打开2个文件时遇到问题。
import os
path = '/home/test/testData/log/'
os.chdir(path)
k = 0
word = 'Log ends'
filename1 = 'test.log'
filename2 = 'tes2.log'
with open(filename1) as firstFile, open(filename2) as secondFile:
for line in firstFile:
if word in line:
print(line)
当我运行脚本时出现错误
python script.py
File "script.py", line 11
with open(filename1) as firstFile, open(filename2) as secondFile:
^
SyntaxError: invalid syntax