ファイルからの文字列をプログラムに入力した文字列と比較するのに問題があります。それらは等しいことを確認する必要がありますが、decode('utf-8')を使用しても、等しくないことがわかります。コードは次のとおりです。
final = open("info", 'r')
exported = open("final",'w')
lines = final.readlines()
for line in lines:
if line == "Wykształcenie i praca": #error
print "ok"
読んでみたファイルの保存方法:
comm_p = bs4.BeautifulSoup(comm)
comm_f.write(comm_p.prettify().encode('utf-8'))
for string in comm_p.strings:
#print repr(string).encode('utf-8')
save = string.encode('utf-8') # there is how i save
info.write(save)
info.write("\n")
info.close()
ファイルの先頭に#---コーディング:utf-8 ---
何か案は?