0
# coding: utf-8

station = open("stations.txt", "r", encoding = "utf-8")

for line in station:
    name = line.strip().split(" - ")
    print(name)

station.close()

If I build this, it shows an error message like below

Traceback (most recent call last):

File "/path/\u1105\u1175\u1109\u1173\u1110\u1173\u1103\u1171\u110c\u1175\u11b8\u1100\u1175(\u110c\u1162\u1100\u1171\u110c\u1165\u11a8).py", line 7, in print(name)

UnicodeEncodeError: 'ascii' codec can't encode characters in position 2-4: ordinal not in range(128)

[Finished in 0.1s with exit code 1]

[cmd: ['/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5', '-u', '/path/name.py']]

[dir: /path/]

[path: /usr/bin:/bin:/usr/sbin:/sbin]

For three days, I couldn't do anything. Help me please

tausun
  • 2,154
  • 2
  • 24
  • 36

0 Answers0