Python3 's Dict

Source: Internet
Author: User
Tags pprint

1 dict1 = {getlisturl:getlistdata,getskuurl:getskudata, approveurl:approvedata, Approvedlisturl: Approvedlistdata, Searchpresellurl:searchpreselldata, deletepresellurl:deletepreselldata}

And then

Import Collections
info = dict (name='cold', blog='linuxzen.com') for in Info.items (): print':', Value

Also learned, Mom egg, call function, stupid cry boingonium hindering:

defkolapprove (URL1, value): Kolrequest= Requests.post (url=url1,json=value,cookies=userlogin.cookies)Print(Kolrequest.url) Pprint (Kolrequest.json ())ifKolrequest.status_code = = 200:        Print(Kolrequest.status_code,kolrequest.reason,'\ n')    Else:        Print(Kolrequest.read ())defMain ():Print('Let\ ' s try it'+'\ n' )     forUR, VAinchDict1.items (): Kolapprove (Ur,va)
# Use Main to start calling main ()

Later found, with dict, not sequential request interface, then changed to list:

#done, the original to be a pair of inside only can use. Items ()defkolapprove (URL1, value): Kolrequest= Requests.post (url=url1,json=value,cookies=userlogin.cookies)Print(Kolrequest.url) Pprint (Kolrequest.json ())ifKolrequest.status_code = = 200:        Print(Kolrequest.status_code,kolrequest.reason,'\ n')    Else:        Print(Kolrequest.read ())defMain ():Print('Let\ ' s try it'+'\ n' )     forNumberinchList1: forUR, VAinchNumber.items (): Kolapprove (Ur,va)

Then, I heard a ordereddict, ordered dictionary, first loaded Utils library, and then:

 from Import ordereddict " "  "' == ordereddict (numbers) for in ordered_ Dict.items ():    print (k,v)

Can not be written directly in the form of a dictionary such as Numbers={a:b,c:d},

should be written numbers = ((A, B), (C,D))

Then use ordered_numbers = ordereddict (numbers) to generate an ordered dictionary,

Then it can be output sequentially, you can request the interface in order, La La la?

Python3 's Dict

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.