I ran into the following problem: I am trying to get a subject and compare it with email (it is saved on disk, email in 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")
Everything seems fine to me, "print" successfully shows me "sub", but the comparison will not print "yay" for me. I can not understand why - (
source
share