{"id":13896,"date":"2023-01-19T17:31:13","date_gmt":"2023-01-19T09:31:13","guid":{"rendered":"https:\/\/docs.pingcode.com\/?p=13896"},"modified":"2023-01-19T17:31:17","modified_gmt":"2023-01-19T09:31:17","slug":"python%e7%9a%84%e6%98%a0%e5%b0%84%e7%b1%bb%e5%9e%8b%e6%9c%89%e5%93%aa%e4%ba%9b","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/13896.html","title":{"rendered":"python\u7684\u6620\u5c04\u7c7b\u578b\u6709\u54ea\u4e9b"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote\">\n<p>python\u7684\u6620\u5c04\u7c7b\u578b\u662f\u5b57\u5178dict\uff0c\u901a\u8fc7key&#8211;>vaule\uff0c\u6784\u6210\u952e\u503c\u5bf9\uff0c\u503c\u4fdd\u5b58\u5728value\u4e2d\uff0ckey\u662f\u5c11\u6570\u7684\u3002\u53ef\u4ee5\u901a\u8fc7key\u627e\u5230\u5bf9\u5e94\u7684value\u3002\u5b83\u4eec\u7684\u952e\u90fd\u5fc5\u987b\u662f\u53ef\u6563\u5217\u7684\u6570\u636e\u7c7b\u578b\u3002\u6620\u5c04\u662f\u4e00\u79cd\u5173\u8054\u5f0f\u7684\u5bb9\u5668\u7c7b\u578b\uff0c\u5b83\u5b58\u50a8\u4e86\u5bf9\u8c61\u4e0e\u5bf9\u8c61\u4e4b\u95f4\u7684\u6620\u5c04\u5173\u7cfb\u3002<\/p>\n<\/blockquote>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"680\" height=\"421\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2023\/01\/\u9ed8\u8ba4\u6807\u9898__2023-01-18-23_22_24.png?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"\" class=\"wp-image-13897\" srcset=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2023\/01\/\u9ed8\u8ba4\u6807\u9898__2023-01-18-23_22_24.png 680w, https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2023\/01\/\u9ed8\u8ba4\u6807\u9898__2023-01-18-23_22_24-300x186.png 300w\" sizes=\"(max-width: 680px) 100vw, 680px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e00\u3001python\u7684\u6620\u5c04\u7c7b\u578b<\/strong><\/h2>\n\n\n\n<p>python\u7684\u6620\u5c04\u7c7b\u578b\u662f\u5b57\u5178dict\uff0c\u901a\u8fc7key&#8211;&gt;vaule\uff0c\u6784\u6210\u952e\u503c\u5bf9\uff0c\u503c\u4fdd\u5b58\u5728value\u4e2d\uff0ckey\u662f\u5c11\u6570\u7684\u3002\u53ef\u4ee5\u901a\u8fc7key\u627e\u5230\u5bf9\u5e94\u7684value\u3002\u5b83\u4eec\u7684\u952e\u90fd\u5fc5\u987b\u662f\u53ef\u6563\u5217\u7684\u6570\u636e\u7c7b\u578b\u3002\u6620\u5c04\u662f\u4e00\u79cd\u5173\u8054\u5f0f\u7684\u5bb9\u5668\u7c7b\u578b\uff0c\u5b83\u5b58\u50a8\u4e86\u5bf9\u8c61\u4e0e\u5bf9\u8c61\u4e4b\u95f4\u7684\u6620\u5c04\u5173\u7cfb\u3002\u5b57\u5178\u662fpython\u91cc\u5c11\u6570\u7684\u6620\u5c04\u7c7b\u578b\uff0c\u5b83\u5b58\u50a8\u4e86\u952e\u503c\u5bf9\u7684\u5173\u8054\uff0c\u662f\u7531\u952e\u5230\u952e\u503c\u7684\u6620\u5c04\u5173\u7cfb\u3002<\/p>\n\n\n\n<p>\u53ef\u6563\u5217\u7684\u6570\u636e\u7c7b\u578b\u6307\u7684\u662f\uff1a\u5728\u8fd9\u79cd\u6570\u636e\u7c7b\u578b\u5bf9\u8c61\u7684\u751f\u547d\u5468\u671f\u4e2d\uff0c\u5b83\u7684\u6563\u5217\u503c\u662f\u4e0d\u53d8\u7684\u3002\u5b83\u4f1a\u5b9e\u73b0 __hash__() \u65b9\u6cd5\u4e0e__qe__() \u65b9\u6cd5\uff0c\u540e\u4e00\u79cd\u65b9\u6cd5\u662f\u7528\u6765\u4e0e\u5176\u4ed6\u952e\u505a\u6bd4\u8f83\u3002\u5982\u679c\u4e24\u4e2a\u5bf9\u8c61\u7684\u6563\u5217\u503c\u76f8\u7b49\uff0c\u90a3\u4e48\u5c31\u53ef\u4ee5\u5224\u5b9a\u8fd9\u4e24\u4e2a\u5bf9\u8c61\u76f8\u7b49\u3002<\/p>\n\n\n\n<p>\u539f\u5b50\u4e0d\u53ef\u53d8\u7684\u6570\u636e\u7c7b\u578b\uff08\u5982\uff1astr\u3001bytes \u548c\u6570\u503c\u7c7b\u578b\uff09\u90fd\u662f\u53ef\u6563\u5217\u6570\u636e\u7c7b\u578b\u3002frozenset \u4e2d\u53ea\u80fd\u5bb9\u7eb3\u53ef\u6563\u5217\u7c7b\u578b\uff0c\u56e0\u6b64\u4e5f\u662f\u53ef\u6563\u5217\u6570\u636e\u7c7b\u578b\u3002<\/p>\n\n\n\n<p>\u4e00\u4e2a\u5b57\u5178\u5bf9\u8c61\u662f\u53ef\u53d8\u7684\uff0c\u4ed6\u662f\u4e00\u4e2a\u5bb9\u5668\u7c7b\u578b\uff0c\u80fd\u5b58\u50a8\u4efb\u610f\u4e2aPython\u5bf9\u8c61\uff0c\u4e5f\u5305\u62ec\u5176\u4ed6\u5bb9\u5668\u7c7b\u578b\u3002\u5b57\u5178\u7c7b\u578b\u548c\u5e8f\u5217\u7c7b\u578b\u7684\u5bb9\u5668\u7c7b\u7684\u533a\u522b\u662f\u5b58\u50a8\u548c\u8bbf\u95ee\u6570\u636e\u7684\u65b9\u5f0f\u4e0d\u540c\u3002\u5e8f\u5217\u53ea\u7528\u6570\u5b57\u7c7b\u578b\u7684\u952e(\u4ece\u5e8f\u5217\u7684\u5f00\u59cb\u6309\u6570<\/p>\n\n\n\n<p>\u5b57\u987a\u5e8f\u7d22\u5f15)\u3002\u800c\u5b57\u5178\u8fd9\u79cd\u6620\u5c04\u7c7b\u578b\u53ef\u4ee5\u7528\u5176\u4ed6\u7c7b\u578b\u505a\u952e\uff0c\u4e00\u822c\u6700\u5e38\u7528\u7684\u662f\u5b57\u7b26\u4e32\u505a\u952e(keys)\u3002<\/p>\n\n\n\n<p>\u521b\u5efa\u5b57\u5178\uff1a\u4e00\u4e2a\u5b57\u5178\u6761\u76ee\u7684\u8bed\u6cd5\u683c\u5f0f\u662f \u952e\uff1a\u503c\uff0c\u591a\u6761\u5b57\u5178\u6761\u76ee\u5305\u542b\u5728{}\u5185\u3002<\/p>\n\n\n\n<p>&gt;&gt;&gt; dict1 = {&#8216;name&#8217;:&#8217;earth&#8217;,&#8217;port&#8217;:80}<\/p>\n\n\n\n<p>&gt;&gt;&gt; dict1<\/p>\n\n\n\n<p>{&#8216;name&#8217;: &#8216;earth&#8217;, &#8216;port&#8217;: 80}<\/p>\n\n\n\n<p>&gt;&gt;&gt;&nbsp;<\/p>\n\n\n\n<p>\u4e5f\u53ef\u4ee5\u5148\u5efa\u4e00\u4e2a\u7a7a\u7684\u5b57\u5178\uff0c\u7136\u540e\u518d\u5f80\u91cc\u9762\u52a0\u5143\u7d20\uff1a<\/p>\n\n\n\n<p>&gt;&gt;&gt; d = {}<\/p>\n\n\n\n<p>&gt;&gt;&gt; d[&#8216;name&#8217;] = &#8216;Gumby&#8217;<\/p>\n\n\n\n<p>&gt;&gt;&gt; d[&#8216;age&#8217;] = 42<\/p>\n\n\n\n<p>&gt;&gt;&gt; d<\/p>\n\n\n\n<p>{&#8216;age&#8217;: 42, &#8216;name&#8217;: &#8216;Gumby&#8217;}<\/p>\n\n\n\n<p>&gt;&gt;&gt;&nbsp;<\/p>\n\n\n\n<p>\u4e5f\u53ef\u4ee5\u7528dict()\u521b\u5efa<\/p>\n\n\n\n<p>&gt;&gt;&gt; fdict = dict(([&#8216;x&#8217;,1],[&#8216;y&#8217;,2]))<\/p>\n\n\n\n<p>&gt;&gt;&gt; fdict<\/p>\n\n\n\n<p>{&#8216;y&#8217;: 2, &#8216;x&#8217;: 1}<\/p>\n\n\n\n<p>&gt;&gt;&gt;&nbsp;<\/p>\n\n\n\n<p><strong>\u5ef6\u4f38\u9605\u8bfb\uff1a<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e8c\u3001python\u5f00\u53d1\u5de5\u5177<\/strong><\/h2>\n\n\n\n<p><strong>Tkinter<\/strong><\/p>\n\n\n\n<p>Python\u9ed8\u8ba4\u7684\u56fe\u5f62\u754c\u9762\u63a5\u53e3\u3002Tkinter\u662f\u4e00\u4e2a\u548cTk\u63a5\u53e3\u7684Python\u6a21\u5757\uff0cTkinter\u5e93\u63d0\u4f9b\u4e86\u5bf9Tk API\u7684\u63a5\u53e3\uff0c\u5b83\u5c5e\u4e8eTcl\/Tk\u7684GUI\u5de5\u5177\u7ec4\u3002<\/p>\n\n\n\n<p><strong>PyGTK<\/strong><\/p>\n\n\n\n<p>\u7528\u4e8epython GUI\u7a0b\u5e8f\u5f00\u53d1\u7684GTK+\u5e93\u3002GTK\u5c31\u662f\u7528\u6765\u5b9e\u73b0GIMP\u548cGnome\u7684\u5e93\u3002<\/p>\n\n\n\n<p><strong>PyQt<\/strong><\/p>\n\n\n\n<p>\u7528\u4e8epython\u7684Qt\u5f00\u53d1\u5e93\u3002QT\u5c31\u662f\u5b9e\u73b0\u4e86KDE\u73af\u5883\u7684\u90a3\u4e2a\u5e93\uff0c\u7531\u4e00\u7cfb\u5217\u7684\u6a21\u5757\u7ec4\u6210\uff0c\u6709qt\uff0cqtcanvas\uff0cqtgl\uff0cqtnetwork\uff0cqtsql\uff0cqttable\uff0cqtui and qtxml\uff0c\u5305\u542b\u6709300\u4e2a\u7c7b\u548c\u8d85\u8fc75750\u4e2a\u7684\u51fd\u6570\u548c\u65b9\u6cd5\u3002PyQt\u8fd8\u652f\u6301\u4e00\u4e2a\u53ebqtext\u7684\u6a21\u5757\uff0c\u5b83\u5305\u542b\u4e00\u4e2aQScintilla\u5e93\u3002\u8be5\u5e93\u662fScintillar\u7f16\u8f91\u5668\u7c7b\u7684Qt\u63a5\u53e3\u3002<\/p>\n\n\n\n<p><strong>wxPython<\/strong><\/p>\n\n\n\n<p>GUI\u7f16\u7a0b\u6846\u67b6\uff0c\u719f\u6089MFC\u7684\u4eba\u4f1a\u975e\u5e38\u559c\u6b22\uff0c\u7b80\u76f4\u662f\u540c\u4e00\u67b6\u6784\uff08\u5bf9\u4e8e\u521d\u5b66\u8005\u6216\u8005\u5bf9\u8bbe\u8ba1\u8981\u6c42\u4e0d\u9ad8\u7684\u7528\u6237\u6765\u8bf4\uff0c\u4f7f\u7528Boa Constructor\u53ef\u4ee5\u65b9\u4fbf\u8fc5\u901f\u7684\u8fdb\u884cwxPython\u7684\u5f00\u53d1\uff09\u5c5e\u4e8e\u5916\u7f6e\u5e93\uff0c\u8981\u5148\u4e0b\u8f7d\u3002<\/p>\n\n\n\n<p><strong>PIL<\/strong><\/p>\n\n\n\n<p>python\u63d0\u4f9b\u5f3a\u5927\u7684\u56fe\u5f62\u5904\u7406\u7684\u80fd\u529b\uff0c\u5e76\u63d0\u4f9b\u5e7f\u6cdb\u7684\u56fe\u5f62\u6587\u4ef6\u683c\u5f0f\u652f\u6301\uff0c\u8be5\u5e93\u80fd\u8fdb\u884c\u56fe\u5f62\u683c\u5f0f\u7684\u8f6c\u6362\u3001\u6253\u5370\u548c\u663e\u793a\u3002\u8fd8\u80fd\u8fdb\u884c\u4e00\u4e9b\u56fe\u5f62\u6548\u679c\u7684\u5904\u7406\uff0c\u5982\u56fe\u5f62\u7684\u653e\u5927\u3001\u7f29\u5c0f\u548c\u65cb\u8f6c\u7b49\u3002\u662fPython\u7528\u6237\u8fdb\u884c\u56fe\u8c61\u5904\u7406\u7684\u5f3a\u6709\u529b\u5de5\u5177\u3002<\/p>\n\n\n\n<p><strong>Psyco<\/strong><\/p>\n\n\n\n<p>\u4e00\u4e2aPython\u4ee3\u7801\u52a0\u901f\u5ea6\u5668\uff0c\u53ef\u4f7fPython\u4ee3\u7801\u7684\u6267\u884c\u901f\u5ea6\u63d0\u9ad8\u5230\u4e0e\u7f16\u8bd1\u8bed\u8a00\u4e00\u6837\u7684\u6c34\u5e73\u3002<\/p>\n\n\n\n<p><strong>xmpppy<\/strong><\/p>\n\n\n\n<p>Jabber\u670d\u52a1\u5668\u91c7\u7528\u5f00\u53d1\u7684XMPP\u534f\u8bae\uff0cGoogle Talk\u4e5f\u662f\u91c7\u7528XMPP\u534f\u8bae\u7684IM\u7cfb\u7edf\u3002\u5728Python\u4e2d\u6709\u4e00\u4e2axmpppy\u6a21\u5757\u652f\u6301\u8be5\u534f\u8bae\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u8be5\u6a21\u5757\u4e0eJabber\u670d\u52a1\u5668\u901a\u4fe1\uff0c\u662f\u4e0d\u662f\u5f88Cool\u3002<\/p>\n\n\n\n<p><strong>PyMedia<\/strong><\/p>\n\n\n\n<p>\u7528\u4e8e\u591a\u5a92\u4f53\u64cd\u4f5c\u7684python\u6a21\u5757\u3002\u5b83\u63d0\u4f9b\u4e86\u4e30\u5bcc\u800c\u7b80\u5355\u7684\u63a5\u53e3\u7528\u4e8e\u591a\u5a92\u4f53\u5904\u7406\uff08wav\uff0cmp3\uff0cogg\uff0cavi\uff0cdivx\uff0cdvd\uff0ccdda etc\uff09\u3002\u53ef\u5728Windows\u548cLinux\u5e73\u53f0\u4e0b\u4f7f\u7528\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0a\u5c31\u662f\u5173\u4e8epython\u7684\u5185\u5bb9\u5e0c\u671b\u5bf9\u5927\u5bb6\u6709\u5e2e\u52a9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"python\u7684\u6620\u5c04\u7c7b\u578b\u662f\u5b57\u5178dict\uff0c\u901a\u8fc7key&#8211;>vaule\uff0c\u6784\u6210\u952e\u503c\u5bf9\uff0c\u503c\u4fdd\u5b58\u5728value\u4e2d\uff0c [&hellip;]","protected":false},"author":1,"featured_media":13897,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/13896"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=13896"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/13896\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/13897"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=13896"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=13896"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=13896"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}