close
UnicodeEncodeError: 'ascii' codec can't encode characters ordinal not in range(128)

這個情況常常發生你在print一個你取出的變數的時候。
可能的情況,
可能是你 print的變數沒辦法在print時轉乘 str

我遇到的情況是從dict get出一個u''的值
所以使用

print x.get('key').encode('utf-8')

encode成utf-8
arrow
arrow
    文章標籤
    python
    全站熱搜

    peicheng 發表在 痞客邦 留言(0) 人氣()