Code to process a JSON file

Source: Internet
Author: User
# encoding=utf-8import Json,rewith Open (' E:\\weather53892_20114.json ', ' R ') as F:    data= F.readlines ()    # Print Data    data1=data[0]    data2= data1[16:-1]    # attribute quotes    data3=re.sub (,?) (\w+?) \s*: ", R" \1 ' \2 ': ", data2)    # turn single quotation marks into double quotes    data_db = data3.replace (" ' "," \ "");    # Coding Problem    Data4=data_db.decode (' GBK '). Encode (' UTF8 ')    print data4    print type (DATA4)    # str Format---> >dict format    data5=json.loads (data4)    print data5[' tqinfo '][0][' ymd ']    print type (DATA5)

 Save it, lest it be lost.

Code to process a JSON file

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.