我有一個file.txt的與輸入Python的讀取和寫入「SS」從並祝
Straße
Straße 1
Straße 2
我想從文件中讀取這段文字並進行打印。我試過了,但它不會奏效。
lmao1 = open('file.txt').read().splitlines()
lmao =random.choice(lmao1)
print str(lmao).decode('utf8')
,但我得到的錯誤
UnicodeDecodeError: 'utf8' codec can't decode byte 0xdf in position 5: invalid continuation byte
你試過沒有'.decode('utf8')'嗎?是的,你不能解碼字符串,只編碼他們 – dhdavvie
https://stackoverflow.com/questions/44309044/unicodedecodeerror-utf-8-invalid-continuation-byte – chrki
沒有'.decode('utf8')'我得到類似'Stra▀e'的輸出 – Dking1199