[英]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.