My problem is String
# -*- coding: utf-8 -*- print ("################################") foo = "142.0000" print (type(foo)) print("foo: "+foo) foo_l = [] foo_l.append(foo) print ("List: " ) print (foo_l) print ("List decode: ") print([x.decode("UTF-8") for x in foo_l]) print("Pop: "+foo_l.pop())
Print result:
This one works fine , I just write the line "CT142H.0000" manually using the keyboard (its same code)
print ("################################") foo = "CT142H.0000" print(type(foo)) print("foo: "+foo) foo_l = [] foo_l.append(foo) print ("List: ") print (foo_l) print ("List decode: ") print([x.decode("UTF-8") for x in foo_l]) print("Pop: "+foo_l.pop())
Print result:
Why does python encode the first line when I add it to the list?
-----------------------------------------------
This is currently resolved, I was worried about it, I put the βresultβ in JSON and then on the website, finally on the website it works great!
-----------------------------------------------
I found another solution, but there is no right solution, because in some cases you will have problems.
json.dumps(list, ensure_ascii=False)
Thanks everyone!
source share