{"id":764,"date":"2022-07-10T03:31:47","date_gmt":"2022-07-10T03:31:47","guid":{"rendered":"https:\/\/blog.liuyingjie.com.cn\/?p=764"},"modified":"2024-03-02T04:19:35","modified_gmt":"2024-03-02T04:19:35","slug":"the-difference-between-python3-function-passing-parameters-and","status":"publish","type":"post","link":"https:\/\/blog.liuyingjie.com.cn\/?p=764","title":{"rendered":"The difference between python3 function passing parameters * and **"},"content":{"rendered":"\n<p><strong>positional argument<\/strong><br><strong>keyword argument<\/strong><\/p>\n\n\n\n<p>The difference between *args and **kwargs, both are variadic arguments in python:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>*args represents any number of unnamed arguments, which is essentially a <strong>tuple<\/strong><\/p>\n\n\n\n<p>**kwargs means keyword arguments, which is essentially a <strong>dict<\/strong><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>When using both *args and **kwargs, the *args argument must be listed before **kwargs.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>Source:<\/strong> Python Crash Course, 2nd Edition A Hands-On: <\/p>\n\n\n\n<p><strong>Note: <\/strong>You\u2019ll often see the generic parameter name *args, which collects arbitrary positional<br>arguments like this.<\/p>\n\n\n\n<p><strong>Note:<\/strong> You\u2019ll often see the parameter name **kwargs used to collect non-specific keyword<br>arguments.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>positional argumentkeyword argument The difference betw &hellip; <a href=\"https:\/\/blog.liuyingjie.com.cn\/?p=764\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">The difference between python3 function passing parameters * and **<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[7],"tags":[],"class_list":["post-764","post","type-post","status-publish","format-standard","hentry","category-python3"],"_links":{"self":[{"href":"https:\/\/blog.liuyingjie.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/764","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.liuyingjie.com.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.liuyingjie.com.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.liuyingjie.com.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.liuyingjie.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=764"}],"version-history":[{"count":7,"href":"https:\/\/blog.liuyingjie.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/764\/revisions"}],"predecessor-version":[{"id":779,"href":"https:\/\/blog.liuyingjie.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/764\/revisions\/779"}],"wp:attachment":[{"href":"https:\/\/blog.liuyingjie.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.liuyingjie.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.liuyingjie.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}