تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
4885 أدوات العرض

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
سبتمبر 24
1909
2
نوفمبر 22
5331
5
أغسطس 19
46507
4
يونيو 18
20054
0
يونيو 18
3270