I am using PyCharm CE 2016.2 and python interpreter 3.5. When I tried to type the following in console, the file is generated with '123'.
>>> with open('man_data.txt', 'w') as data:
print('123', file=data)
However, when I put the same statement into a test.py file and try to run it using subprocess.call(['python', 'test.py']), it gives
>>> subprocess.call(['python', 'test.py'])
File "test.py", line 2
print('123', file=data)
^
SyntaxError: invalid syntax
1
Does anyone has any clues? Million thanks!