My goal is to simply have +1 and -1 in my output.txt file, yet I keep getting Chinese characters
ㄭㄫㄫㄫㄫㄭ
The code snippet below works fine in a separate Python file:
f = open('C:\\Users\\Max\\Downloads\\output.txt', 'w', encoding='ascii')
f.write('+1')
f.write('-1')
Yet generates Chinese characters when I put it into another project:
if(algorithm==1):
f.write('+1')
else:
f.write('-1')
The code is successfully going into the if/else statements (debugged). Any idea on what's wrong?
Used
encoding='cp1252'
And it printed out successfully without having to use '\n'. Caught it when PyCharm listed it on the debugger while debugging.