2016-11-14 16 views
1

私はPython 2.7.12を搭載したWindows 7と、Python 2.6.6を搭載したRed Hat Enterprise Linux Server 6.5をサポートしています。なぜPythonスクリプトはLinuxではなくWindows上で動作しますか?

私はWindowsではうまく動作しますが、RHELではうまく動作しないスクリプトがあります。

私は、次の構文エラーが表示されます。

with open('pathtofile', 'rb') as f_input, open('pathtofile', 'w') as f_output: 
#          ^ 

SyntaxError: invalid syntax 
それは二つのシステム上のPythonの異なるバージョンによって引き起こされる可能性が

答えて

3
with open('pathtofile', 'rb') as f_input, open('pathtofile', 'w') as f_output: 

は、Python 2.6ではサポートされていません。そのバージョンでは、withステートメントで1つのファイルしか開くことができません。代わりに、行うことができます

with open('pathtofile', 'rb') as f_input: 
    with open('pathtofile', 'w') as f_output: 
関連する問題