Home > front end >  Why doesn't this decode function working in python2?
Why doesn't this decode function working in python2?

Time:09-17

I am debugging a python2 code:

tag_list = [convert(tag) for tag in tag_list]
print('tag_list: ', str(tag_list).decode("utf-8"))

However, the print out is like below:

u"['\\xe4\\xba\\xa4\\xe9\\x80\\x9a\\xe6\\x9c\\x8d\\xe5\\x8a\\xa1', '\\xe7\\xa4\\xbe\\xe4\\xbc\\x9a', '\\xe7\\x94\\xb5\\xe8\\xa7\\x86\\xe5\\x89\\xa7', '\\xe9\\x9f\\xb3\\xe4\\xb9\\x90']"

How to correctly print out the actual strings, instead of those x codes?

CodePudding user response:

print("["   ", ".join(tag_list)   "]")

I guess would give you the output you want ... maybe

  • Related