I have from one side Windows 7 with Python 2.7.12 and on the other side Red Hat Enterprise Linux Server release 6.5 with Python 2.6.6.
I have a script that works fine on Windows but not on RHEL.
I receive the following syntax error:
with open('pathtofile', 'rb') as f_input, open('pathtofile', 'w') as f_output:
# ^
SyntaxError: invalid syntax
It may be caused by different versions of Python on the two systems?
with open('pathtofile', 'rb') as f_input, open('pathtofile', 'w') as f_output:
is not supported by Python 2.6. In that version you can only open one file in the with
statement. Instead, you can do
with open('pathtofile', 'rb') as f_input:
with open('pathtofile', 'w') as f_output:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.