我想打开一个包含丹麦语,ø和å字母的文件。 当我打开文件时,我想组织保存文件输出的字符串中的单词和字母。
不幸的是;当我试图看看这些字母中的任何一个是否是字符串的一部分时,输出结果为no。这是我的计划:
wordlist = open("_newWordList.txt", "r")
print("Opened newwordlist")
for lineNo, content in enumerate(wordlist):
s_line = content.split(";")
print(str(lineNo)+": Checking the content: "+str(s_line)+" on line number: "+str(lineNo))
ok = s_line[1]
if ok[:4] == "adj.":
adj = adj + s_line[0]
elif ok[:10] == "ubøj. adj.":
adj = adj + s_line[0]
elif ok[:4] == "adv.":
adv = adv + s_line[0]
elif ok[:5] == "fork.":
fork = fork + s_line[0]
elif ok[:8] == "præfiks.":
præfiks = præfiks + s_line[0]
elif ok[:5] == "præp.":
praep = praep + s_line[0]
elif ok[:5] == "pron.":
pron = pron + s_line[0]
elif ok[:5] == "prop.":
prop = prop + s_line[0]
elif ok[:3] == "sb.":
sb = sb + s_line[0]
elif ok[:7] == "sb. pl.":
sb = sb + s_line[0]
elif ok[:9] == "udråbsord":
uro = uro + s_line[0]
elif ok[:3] == "vb.":
vb = vb + s_line[0]
else:
print(" ")
print("Error; didn't read any wordclass in the word: "+str(lineNo+1)+" : "+str(content))
print("The wordclass is: "+ok)
totalErrors += 1
这些字母是奇怪的,不可读的符号。