我想連接兩個字符串是這樣的:在我的情況Python的連接字符串 - 的UnicodeDecodeError:「ASCII」編解碼器不能解碼字節
requestData = command + ' ' + data
「數據」持有二進制數據,不應該打開 - 它應該只是粘在命令上。但是,imho python試圖打開它,但它失敗:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xbc in position 1: ordinal not in range(128)
有沒有辦法將它粘貼而不打開?
編輯: Python 2.7 另外我的數據實際上不是UTF-8解碼可能無法幫助 - 它的二進制數據。
哪個Python版本是這樣的嘗試?必須是2.something,但Python 2.7.3成功連接非ASCII字符串:'In [1]:'привет'+''+'Veseliq' Out [1]:'\ xd0 \ xbf \ xd1 \ x80 \ xd0 \ xb8 \ xd0 \ xb2 \ xd0 \ xb5 \ xd1 \ x82 Veseliq''。 –
其python 2.7,數據是misc二進制數據 – ddinchev
是'command' unicode?如果是,首先「編碼」。 – georg