当我在 python 中运行这个简单的程序时,我在“for line in file”之后得到一个 ascii 错误。我尝试了许多更改但没有成功。为什么我会遇到这个问题?
代码:
flashcards = {}
def Gaelic():
file = open ("gaelic_flashcard_mode.txt", "r")
for line in file:
print("clear4")
line1 = line.rstrip().split("=")
key = line1[0]
trans = line1[1]
PoS = line1[2]
flashcards[key] = [trans, PoS]
print(flashcards)
正在读取的文本文件(gaelic_flashcard_mode.txt):
I=mé=(pron) (emphatic)
I=mise=(n/a)
you=tú=(pron) (subject)
you=tusa=(emphatic)
y'all=sibh=(plural)
y'all=sibhse=(emphatic)
he=sé=(pron)
he=é=(n/a)
he=seisean=(emphatic)
he=eisean=(n/a)
she=sí=(pron)
she=í=(n/a)
she=sise=(emphatic)
she=ise=(emphatic)
him=é=(pron)
him=eisean=(emphatic)
her=í=(pron)
her=ise=(emphatic)
her=a=(adj)