I have printed “a” in my file.
However when I operate my code,it return 0.
I am puzzled for hours.Thank you for your help!
Do not post screenshots of text. Please read About the Python Help category and modify your post accordingly.
1 Like
How did the file get created? Both U+0061 and U+0430 look similar, for example:
>>> print(chr(0x61))
a
>>> print(chr(0x0430))
а
Check the result of [ord(x) for x in f.read())]
to see what characters you really read from your file.
Does the file contain what you think it contains?
Try:
print(ascii(a))
Can you put this code at the end of your file and re-run the program, then tell us what it prints?
print([ord(c) for c in a])
You might be opening a different file than then the one you saved.