JSON sequence of Python

Source: Internet
Author: User

# from Urllib Import request
#
# F=request.urlopen ("http://123.178.101.29:81/xs_main.aspx?xh=201512102028")
#
# RESULT=STR (F.read (), encoding= ' gb2312 ')
# Print (Result)
#json. Loads used to convert a dictionary, a list, a tuple form string, to a corresponding amount dictionary, a list, a tuple
#利用json把字符串变成字典
# s= ' {"name": "Guo", "Age": 18} '
# import JSON
# result=json.loads (s)
# Print (Result,type (result))

#把字符串改成列表
# l= ' [11,22,33,44] '
# import JSON
# result=json.loads (L)
# Print (Result,type (result))

#json. Loads () function is to convert a string into a python base data type
#json. Dumps () function is to convert the basic type of Python to a string
# lists=["Alex", "Guo", "Xiaolu"]
# import JSON
# s=json.dumps (lists)
# print (s)

#json = string (content is list, tuple, dictionary form)
#http请求相应内容字符串


#json. Load () reads content from a file
#json. Dump () converts the dictionary into a file
# import JSON
# dic={' K1 ': 123, ' K2 ': 23}
# S=json.dump (Dic,open (' db ', ' W '))
# print (s)
# import JSON
# r=json.load (Open (' db ', ' r '))
# Print (R,type (R))

#会把元组转换为列表输出
n= (11,22,33,44, ' alexf ')
Import JSON
S=json.dumps (N)
Print (s)

JSON sequence of Python

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.