In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
Most people do not understand the knowledge points of this article "what is the role of json coding in python3", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "what is the role of json coding in python3" article.
Here is an example:
In: json.dumps ('Chinese', ensure_ascii=True) Out [121]:'\\ u4e2d\\ u6587''In [122]: json.dumps ('Chinese', ensure_ascii=False) Out [122]: 'Chinese' copy code
You can see that when ensure_ascii is True, Chinese is encoded into Unicode code, which can only be displayed normally for False, but what does this have to do with ASCII? Let's take a look at the official documentation's explanation of this parameter:
If ensure_ascii is true (that is, the default), the output guarantees that all input non-ASCII characters will be escaped. If ensure_ascii is false, these characters are output as is.
Copy the code
Now it is slightly understood that when ensure_ascii is True, if there is a non-ASCII character in the string, it will be escaped. According to the result, we can know that this character has been escaped into Unicode code and formatted into a string. Note that "\\ u4e2d\\ u6587" is different from "\ u4e2d\\ u6587". The former is a string of length 12, and the latter will be directly parsed into Chinese by Python. The length is 2. This is my initial problem, directly escaping the string over the network may not be recognized. For example, Chinese is escaped to\\ u4e2d\\ U6587, and if the server does not know that it is an escaped string, then it is an ordinary string with a length of 12, which is bound to make an error. Setting ensure_ascii to False will not escape and use the original characters.
The above is about the content of this article on "what is the role of json coding in python3". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.