[英]Why does a Python script work on Windows and not in Linux?
我从一端使用带有Python 2.7.12的Windows 7,另一端使用带有Python 2.6.6的Red Hat Enterprise Linux Server 6.5版。
我有一个在Windows上运行良好但在RHEL上运行不正常的脚本。
我收到以下语法错误:
with open('pathtofile', 'rb') as f_input, open('pathtofile', 'w') as f_output:
# ^
SyntaxError: invalid syntax
它可能是由两个系统上不同版本的Python引起的?
with open('pathtofile', 'rb') as f_input, open('pathtofile', 'w') as f_output:
Python 2.6不支持。 在该版本中,您只能在with
语句中打开一个文件。 相反,你可以做到
with open('pathtofile', 'rb') as f_input:
with open('pathtofile', 'w') as f_output:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.