Python a little bit of common sense

Source: Internet
Author: User

In Python, there are two variable-length parameters, the tuple (non-keyword argument) and the dictionary (keyword parameter), whose parameters represent an arbitrary-length tuple [tuple] at the beginning of a *, and can receive successive strings of arguments, with the argument starting with two * to represent a dictionary [dict], or "key:value , accept any number of consecutive arguments.

  1. # # #示例函数 # #
  2. def Variable(*arg, * *Kwargs):
  3. Print arg
  4. print Kwargs
  5. print "\ n"
  6. # # #执行输出tuple # #
  7. >>> Variable(1,2,3,4,5,"www"," I-it "," info ")
  8. (1, 2, 3, 4, 5, ' www ', ' i-it ' , ' info ')
  9. {}
  10. # # #执行输出dict # #
  11. >>> Variable(www=1,IIT=2,info=3)
  12. ()
  13. {' info ': 3, ' IIT ': 2, ' www ': 1}
  14. # #一起来 # #
  15. >>> variable ( Span class= "lit" >1,2,3 ,4,5 www=1,iit =2,info= 3)
  16. (1, 2, 3, 4, 5)
  17. {' info ': 3, ' IIT ': 2, ' www ': 1 }

Python a little bit of common sense

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.