Joke Collection Website - Public benefit messages - What if python string is garbled?
What if python string is garbled?
Therefore, when encoding conversion, it is usually necessary to use unicode as the intermediate encoding, that is, first decode other encoded strings into unicode, and then encode them from unicode into another encoding.
Decode is used to convert other encoded strings into unicode encoding, such as string 1.decode('utf-8'), which means that utf-8 encoded string 1 is converted into unicode encoding.
The function of encode is to convert unicode encoding into other encoded strings, such as string2.encode('utf-8'), which means to convert unicode encoded string string2 into utf-8 encoding.
If a string is already unicode, it is wrong to decode it again, so it is usually necessary to judge whether its encoding method is unicode:
Isinstance(string3, unicode) # is used to determine whether string3 is encoded in unicode.
String3 encoding using non-unicode unicoded encoding will also cause errors.
It is recommended to learn Python tutorial!
- Previous article:Bank of Communications credit card downgrade SMS content
- Next article:Congratulatory message to outgoing colleagues
- Related articles
- Humorous blessings, poems and greetings
- Is it true that Alipay customer service said to send materials?
- Five content schemes of kindergarten drowning prevention safety education in 2022
- Beijing Mid-Autumn Festival restrictions
- Taobao Shopping Logistics details what will happen to your package after it leaves the warehouse.
- How to delete spam messages on Xi 'an mobile phone?
- Blessings for travel
- Thank my lover for being kind to me.
- Common sense of fire escape and self-help
- I don't think so. What do I think is ok?