Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2 Vastaukset
4891 Näkymät

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?

 


Avatar
Hylkää
Paras vastaus

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')


Avatar
Hylkää
Tekijä Paras vastaus

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


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


Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
2
syysk. 24
1913
2
marrask. 22
5347
5
elok. 19
46516
4
kesäk. 18
20062
0
kesäk. 18
3280