コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
4870 ビュー

purchase order line has a field "name" witch is the SKU + Product Name +',' + suppliers product desc. 

if I split name on ',' and print the supplier product desc. part of the array it writes a string starting with u' (unicode)

how do i encode the string so it is printed correct?


Prints something like:

[SKU-123] Product Name

[u'Vendors product description \u0142a + bla bla']


How do print it correctly?

 


アバター
破棄
最善の回答

Try this,

unicode_string = unicode_string.encode('ascii','ignore')

Here I update my answer, you cant encode the list object, you need to encode the list elements, i.e. list[0], list[1] or in whatever index that your target value is sitting.

list_element = list_element[0].encode('ascii','ignore')


アバター
破棄
著作者 最善の回答

yeah .. i forgot to tell i already tried that but with utf8. I doesn't work.


QWebException: 'list' object has no attribute 'encode'


アバター
破棄
関連投稿 返信 ビュー 活動
2
9月 24
1899
2
11月 22
5326
5
8月 19
46505
4
6月 18
20051
0
6月 18
3267