我有比較字符串與我在程序中輸入字符串的問題,我應該得到他們是平等的,但不管如果我使用解碼('utf-8')我得到他們是不平等的。下面的代碼:python編碼
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 - -
任何想法?
加上'打印 「%R%R」 %(行, 「我Wykształcenie普拉查」) 「就在比較線之前,告訴我們它說的是什麼 – georg