I run the program b.py how can I make the third line of the output look the same as the first b.py:
S='----Ăł---'
def x(S):
print(f'{S=}')
RES=[]
for s in S:
RES+=[ord(s)]
return RES
print(x(S)) # first line result
with open('b.py') as F:
print(x(F.readlines()[0])) # thrid line result
I found the answer: open the file with encofding = 'utf_8':
`with open ('b.py, encoding =' utf_8 ') as F:
....
'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.