我遇到了以下问题:我正在尝试从电子邮件中获取主题和比较(它保存在磁盘上,以 UTF-8 发送电子邮件)
import re
def check_subj():
subj = ""
file = open("/home/hikaru/Desktop/sub.eml", "r")
for line in file:
try:
a = re.search("Subject:\ ", line, re.IGNORECASE)
a = line[a.end():]
subj = a
break
except AttributeError:
pass
return subj
print(check_subj())
if check_subj() == 'sub':
print("yay")
对我来说一切都很好,“打印”成功地向我展示了“子”,但比较不会为我打印“耶”。我不明白为什么-(