Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
4905 มุมมอง

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'


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ก.ย. 24
1922
2
พ.ย. 22
5375
How do i create report in Qweb? แก้ไขแล้ว
5
ส.ค. 19
46526
4
มิ.ย. 18
20084
0
มิ.ย. 18
3291