# Reference: the python standard library by example
12.9 JSON Module
JSON is JavaScript Object Notation. This module converts Python objects and JSON strings. Applicable to Python version 2.6 and later.The JSON module provides an API similar to
# 1 JSON string length like dictionary, but not dictionary type, is str type#例如: User_info is a JSON string, Dict is a dictionary, if the content of the TXT text that identifies dict is a JSON stringUser_info = "'{"name1": "Lily", "name2": "tt",
The coding problem of Python3 has been relatively simple In-memory strings are Unicode Save to file with Utf-8 The following are the processes that str,byte convert to each other:str = "ABC Learning "StrOUT[6]: ' ABC Learning 'MyByte =
JSON (JavaScript Object Notation) is a lightweight data interchange format. It is based on a subset of ECMAScript.1, Json.dumps () and json.loads () are JSON format processing functions (so to understand, JSON is a string)
The Json.dumps ()
Json.dumps is the encoding parsing of a Python data type list in JSON format,Examples are as follows:>>> import JSON module in JSON #导入python>>> L = [' Iplaypython ', [n/a], {' name ': ' Xiaoming '}] #创建一个l列表>>> Encoded_json = Json.dumps (l) # List
The basic features are explained first:Dumps is converting dict to str format, loads is converting str to dict format.Dump and load are similar functions, just combined with file operations.Look at the code example:In [1]:ImportJSON in [2]: a =
python2.x version of the character encoding sometimes makes people very headache, encounter problems, online method can solve the error, but the principle or smattering, this article mainly introduces the principle of string processing in Python,
python2.x version of the character encoding sometimes makes people very headache, encounter problems, online method can solve the error, but the principle or smattering, this article mainly introduces the principle of string processing in Python,
(a) What is JSON:
JSON (JavaScript Object notation) is a lightweight data interchange format. Easy for people to read and write. It is also easy to machine parse and generate. It is based on JavaScript programming Language, Standard ECMA-262 a
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.