{"id":212,"date":"2023-09-09T18:32:38","date_gmt":"2023-11-07T00:11:55","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/index.php\/2023\/11\/30\/python-%e9%9b%86%e5%90%88\/"},"modified":"2025-08-01T02:27:54","modified_gmt":"2025-07-31T18:27:54","slug":"python-%e9%9b%86%e5%90%88","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/python-%e9%9b%86%e5%90%88\/","title":{"rendered":"Python\u96c6\u5408\uff1a\u6df1\u5165\u7406\u89e3\u6570\u636e\u7ed3\u6784\u4e0e\u9ad8\u6548\u5e94\u7528"},"content":{"rendered":"<div><img decoding=\"async\" class=\"post-images\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/6564792ea4b2f92e6c72b016\/0-0.jpg\" alt=\"Python Set, python set example\" title=\"Python \u96c6\u5408\u793a\u4f8b\" \/><\/div>\n<h2>Python \u96c6\u5408\u8be6\u89e3<\/h2>\n<p>Python \u96c6\u5408\uff08Set\uff09\u662f\u4e00\u4e2a\u65e0\u5e8f\u4e14\u5143\u7d20\u552f\u4e00\u7684\u96c6\u5408\u3002\u5f53\u60a8\u9700\u8981\u4ece\u5217\u8868\u4e2d\u63d0\u53d6\u552f\u4e00\u5143\u7d20\uff0c\u6216\u8005\u4ec5\u4ece\u8f93\u5165\u4e2d\u83b7\u53d6\u4e0d\u91cd\u590d\u7684\u6570\u636e\u65f6\uff0cPython \u96c6\u5408\u662f\u7406\u60f3\u7684\u9009\u62e9\u3002\u60a8\u53ef\u4ee5\u65b9\u4fbf\u5730\u5411\u96c6\u5408\u4e2d\u6dfb\u52a0\u6216\u5220\u9664\u5143\u7d20\u3002<\/p>\n<p>\u521d\u59cb\u5316\u96c6\u5408\u53ef\u4ee5\u901a\u8fc7\u5c06\u5143\u7d20\u653e\u7f6e\u5728\u82b1\u62ec\u53f7 <code>{}<\/code> \u4e4b\u95f4\u5b9e\u73b0\u3002\u4e0e\u5217\u8868\u7b49\u5176\u4ed6\u5e8f\u5217\u7c7b\u4f3c\uff0c\u96c6\u5408\u53ef\u4ee5\u5305\u542b\u591a\u79cd\u6570\u636e\u7c7b\u578b\u7684\u5143\u7d20\u3002\u6b64\u5916\uff0c\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528 <code>set()<\/code> \u51fd\u6570\u4ece\u73b0\u6709\u5217\u8868\u4e2d\u521b\u5efa\u96c6\u5408\u3002\u4ee5\u4e0b\u793a\u4f8b\u5c06\u4e3a\u60a8\u5c55\u793a\u5982\u4f55\u521d\u59cb\u5316\u548c\u521b\u5efa\u96c6\u5408\uff1a<\/p>\n<pre class=\"post-pre\"><code># \u5305\u542b\u5355\u4e00\u6570\u636e\u7c7b\u578b\u7684\u96c6\u5408\r\nset1 = {1, 2, 3, 4, 2, 3, 1}\r\nprint(set1)\r\n\r\n# \u5305\u542b\u591a\u79cd\u6570\u636e\u7c7b\u578b\u7684\u96c6\u5408\r\nset2 = {1, 2, 3, (1, 2, 3), 2.45, \"Python\", 2, 3}\r\nprint(set2)\r\n\r\n# \u4ece\u5217\u8868\u521b\u5efa\u96c6\u5408\r\ntheList = [1, 2, 3, 4, 2, 3, 1]\r\ntheSet = set(theList)\r\nprint(theSet)\r\n<\/code><\/pre>\n<p>\u4ee5\u4e0b\u662f\u4e0a\u8ff0\u4ee3\u7801\u7684\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n<pre class=\"post-pre\"><code>================== RESTART: \/home\/imtiaz\/set1.py ==================\r\n{1, 2, 3, 4}\r\n{1, 2, 3, 2.45, 'Python', (1, 2, 3)}\r\n{1, 2, 3, 4}\r\n&gt;&gt;&gt; \r\n<\/code><\/pre>\n<h3>\u5411 Python \u96c6\u5408\u4e2d\u6dfb\u52a0\u5143\u7d20<\/h3>\n<p>\u5728\u524d\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5b66\u4e60\u4e86\u5982\u4f55\u76f4\u63a5\u521d\u59cb\u5316 Python \u96c6\u5408\u3002\u5982\u679c\u60a8\u9700\u8981\u5411\u96c6\u5408\u4e2d\u6dfb\u52a0\u65b0\u5143\u7d20\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>add()<\/code> \u51fd\u6570\u3002\u4f46\u8bf7\u6ce8\u610f\uff0c<code>add()<\/code> \u51fd\u6570\u4e00\u6b21\u53ea\u80fd\u6dfb\u52a0\u4e00\u4e2a\u5143\u7d20\u3002\u5982\u679c\u60a8\u60f3\u6dfb\u52a0\u53ef\u8fed\u4ee3\u7684\u5143\u7d20\uff08\u5982\u5217\u8868\u6216\u53e6\u4e00\u4e2a\u96c6\u5408\uff09\uff0c\u5219\u5e94\u4f7f\u7528 <code>update()<\/code> \u51fd\u6570\u3002\u4ee5\u4e0b\u793a\u4f8b\u5c06\u5e2e\u52a9\u60a8\u7406\u89e3\u8fd9\u4e24\u79cd\u6dfb\u52a0\u65b9\u5f0f\uff1a<\/p>\n<pre class=\"post-pre\"><code># \u521d\u59cb\u5316\u4e00\u4e2a\u7a7a\u96c6\u5408\r\ntheSet = set()\r\n\r\n# \u4f7f\u7528 add() \u51fd\u6570\u6dfb\u52a0\u5355\u4e2a\u5143\u7d20\r\ntheSet.add(1)\r\ntheSet.add(2)\r\ntheSet.add(3)\r\ntheSet.add(2) # \u91cd\u590d\u5143\u7d20\u4e0d\u4f1a\u88ab\u6dfb\u52a0\r\n# \u6dfb\u52a0\u5176\u4ed6\u6570\u636e\u7c7b\u578b\r\ntheSet.add('hello')\r\n\r\n# \u4f7f\u7528 update() \u51fd\u6570\u6dfb\u52a0\u53ef\u8fed\u4ee3\u5143\u7d20\r\ntheSet.update([1,2,4,'hello','world']) # \u5217\u8868\u4f5c\u4e3a\u53ef\u8fed\u4ee3\u5143\u7d20\r\ntheSet.update({1,2,5}) # \u96c6\u5408\u4f5c\u4e3a\u53ef\u8fed\u4ee3\u5143\u7d20\r\nprint(theSet)\r\n<\/code><\/pre>\n<p>\u4ee5\u4e0b\u662f\u4e0a\u8ff0\u4ee3\u7801\u7684\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n<pre class=\"post-pre\"><code>================== RESTART: \/home\/imtiaz\/set_new.py ==================\r\n{1, 2, 3, 4, 5, 'world', 'hello'}\r\n&gt;&gt;&gt; \r\n<\/code><\/pre>\n<h3>\u4ece Python \u96c6\u5408\u4e2d\u5220\u9664\u5143\u7d20<\/h3>\n<p>\u4ece Python \u96c6\u5408\u4e2d\u5220\u9664\u5143\u7d20\u4e3b\u8981\u6709\u4e24\u79cd\u65b9\u6cd5\uff1a\u4f7f\u7528 <code>remove()<\/code> \u51fd\u6570\u6216 <code>discard()<\/code> \u51fd\u6570\u3002\u5b83\u4eec\u7684\u4e3b\u8981\u533a\u522b\u5728\u4e8e\uff1a\u5982\u679c\u5c1d\u8bd5\u5220\u9664\u7684\u5143\u7d20\u4e0d\u5728\u96c6\u5408\u4e2d\uff0c<code>remove()<\/code> \u51fd\u6570\u4f1a\u629b\u51fa <code>KeyError<\/code> \u5f02\u5e38\uff0c\u800c <code>discard()<\/code> \u51fd\u6570\u5219\u4e0d\u4f1a\u6267\u884c\u4efb\u4f55\u64cd\u4f5c\uff0c\u4e5f\u4e0d\u4f1a\u62a5\u9519\u3002\u4ee5\u4e0b\u4ee3\u7801\u5c06\u6f14\u793a\u8fd9\u4e24\u79cd\u51fd\u6570\u7684\u4f7f\u7528\uff1a<\/p>\n<pre class=\"post-pre\"><code>theSet = {1,2,3,4,5,6}\r\n\r\n# \u4f7f\u7528 discard() \u51fd\u6570\u5220\u9664\u5143\u7d20 3\r\ntheSet.discard(3)\r\nprint(theSet)\r\n\r\n# \u518d\u6b21\u8c03\u7528 discard() \u51fd\u6570\u5220\u9664\u5143\u7d20 3\r\ntheSet.discard(3) # \u8fd9\u4e0d\u4f1a\u5f15\u53d1\u4efb\u4f55\u5f02\u5e38\uff0c\u56e0\u4e3a 3 \u5df2\u7ecf\u4e0d\u5b58\u5728\r\nprint(theSet)\r\n\r\n# \u8c03\u7528 remove() \u51fd\u6570\u5220\u9664\u5143\u7d20 5\r\ntheSet.remove(5)\r\nprint(theSet)\r\n\r\n# \u518d\u6b21\u8c03\u7528 remove() \u51fd\u6570\u5220\u9664\u5143\u7d20 5\r\ntheSet.remove(5) # \u8fd9\u5c06\u5f15\u53d1\u5f02\u5e38\uff0c\u56e0\u4e3a 5 \u5df2\u7ecf\u4e0d\u5b58\u5728\r\nprint(theSet) # \u8fd9\u884c\u4ee3\u7801\u5c06\u4e0d\u4f1a\u88ab\u6267\u884c\r\n<\/code><\/pre>\n<p>\u60a8\u5c06\u4f1a\u770b\u5230\u5982\u4e0b\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n<pre class=\"post-pre\"><code>================== RESTART: \/home\/imtiaz\/set_del.py ==================\r\n{1, 2, 4, 5, 6}\r\n{1, 2, 4, 5, 6}\r\n{1, 2, 4, 6}\r\n\r\nTraceback (most recent call last):\r\n  File \"\/home\/imtiaz\/set_del.py\", line 16, in \r\n    theSet.remove(5) # this would raise exception\r\nKeyError: 5\r\n&gt;&gt;&gt; \r\n<\/code><\/pre>\n<h3>Python \u96c6\u5408\u64cd\u4f5c<\/h3>\n<p>\u60a8\u53ef\u80fd\u5bf9\u6570\u5b66\u4e2d\u7684\u96c6\u5408\u64cd\u4f5c\uff0c\u5982\u5e76\u96c6\u3001\u4ea4\u96c6\u548c\u5dee\u96c6\u6bd4\u8f83\u719f\u6089\u3002Python \u96c6\u5408\u4e5f\u63d0\u4f9b\u4e86\u8fd9\u4e9b\u529f\u80fd\u3002\u73b0\u5728\uff0c\u6211\u4eec\u6765\u5b66\u4e60\u5982\u4f55\u5229\u7528 Python \u5b9e\u73b0\u8fd9\u4e9b\u96c6\u5408\u64cd\u4f5c\u3002<\/p>\n<h3>Python \u96c6\u5408\u7684\u5e76\u96c6<\/h3>\n<p>\u96c6\u5408\u7684\u5e76\u96c6\u64cd\u4f5c\u662f\u5c06\u4e24\u4e2a\u96c6\u5408\u5408\u5e76\uff0c\u751f\u6210\u4e00\u4e2a\u5305\u542b\u4e24\u4e2a\u96c6\u5408\u4e2d\u6240\u6709\u552f\u4e00\u5143\u7d20\u7684\u65b0\u96c6\u5408\u3002\u4f8b\u5982\uff0c\u5982\u679c\u96c6\u5408 A \u662f <code>{1, 2, 3, 4}<\/code>\uff0c\u96c6\u5408 B \u662f <code>{2, 3, 5, 7}<\/code>\u3002\u5bf9\u5b83\u4eec\u8fdb\u884c\u5e76\u96c6\u64cd\u4f5c\u540e\uff0c\u6211\u4eec\u5c06\u5f97\u5230 <code>{1, 2, 3, 4, 5, 7}<\/code>\u3002\u5728 Python \u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 <code>union()<\/code> \u51fd\u6570\u6765\u5b9e\u73b0\u5e76\u96c6\u3002<\/p>\n<h3>Python \u96c6\u5408\u7684\u4ea4\u96c6<\/h3>\n<p>\u96c6\u5408\u7684\u4ea4\u96c6\u64cd\u4f5c\u662f\u627e\u51fa\u4e24\u4e2a\u96c6\u5408\u4e2d\u5171\u540c\u7684\u552f\u4e00\u5143\u7d20\uff0c\u5e76\u751f\u6210\u4e00\u4e2a\u65b0\u96c6\u5408\u3002\u4f8b\u5982\uff0c\u5982\u679c\u96c6\u5408 A \u662f <code>{1, 2, 3, 4}<\/code>\uff0c\u96c6\u5408 B \u662f <code>{2, 3, 5, 7}<\/code>\u3002\u5bf9\u5b83\u4eec\u8fdb\u884c\u4ea4\u96c6\u64cd\u4f5c\u540e\uff0c\u6211\u4eec\u5c06\u5f97\u5230 <code>{2, 3}<\/code>\u3002\u4ea4\u96c6\u64cd\u4f5c\u7531 <code>intersection()<\/code> \u51fd\u6570\u5b8c\u6210\u3002<\/p>\n<h3>Python \u96c6\u5408\u7684\u5dee\u96c6<\/h3>\n<p>\u5dee\u96c6\u64cd\u4f5c\u6bd4\u8f83\u4e24\u4e2a\u96c6\u5408\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u65b0\u96c6\u5408\uff0c\u5176\u4e2d\u5305\u542b\u7b2c\u4e00\u4e2a\u96c6\u5408\u4e2d\u6709\u800c\u7b2c\u4e8c\u4e2a\u96c6\u5408\u4e2d\u6ca1\u6709\u7684\u5143\u7d20\u3002\u5047\u8bbe\u6211\u4eec\u6709\u4e24\u4e2a\u96c6\u5408\uff1aA = <code>{1, 2, 3, 4}<\/code> \u548c B = <code>{2, 3, 5, 7}<\/code>\u3002\u90a3\u4e48\uff0cA &#8211; B \u64cd\u4f5c\u5c06\u751f\u6210 <code>{1, 4}<\/code>\u3002\u540c\u6837\u5730\uff0cB &#8211; A \u5c06\u751f\u6210 <code>{5, 7}<\/code>\u3002\u5dee\u96c6\u64cd\u4f5c\u7531 <code>difference()<\/code> \u51fd\u6570\u5b8c\u6210\u3002\u4ee5\u4e0b\u4ee3\u7801\u5c06\u4e3a\u60a8\u5c55\u793a\u5982\u4f55\u5728 Python \u7f16\u7a0b\u4e2d\u6267\u884c\u8fd9\u4e9b\u96c6\u5408\u64cd\u4f5c\uff1a<\/p>\n<pre class=\"post-pre\"><code>A = {1, 2, 3, 4} # \u521d\u59cb\u5316\u96c6\u5408 A\r\nB = {2, 3, 5, 7} # \u521d\u59cb\u5316\u96c6\u5408 B\r\n\r\nunion_operation = A.union(B)\r\n\r\nprint(\"A \u5e76\u96c6 B :\")\r\nprint(union_operation)\r\n\r\nintersection_operation = A.intersection(B)\r\n\r\nprint(\"A \u4ea4\u96c6 B :\")\r\nprint(intersection_operation)\r\n\r\ndifference_operation = A.difference(B)\r\n\r\nprint(\"A - B :\")\r\nprint(difference_operation)\r\n\r\ndifference_operation = B.difference(A)\r\nprint(\"B - A :\")\r\nprint(difference_operation)\r\n<\/code><\/pre>\n<p>\u60a8\u5c06\u5f97\u5230\u5982\u4e0b\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n<pre class=\"post-pre\"><code>================== RESTART: \/home\/imtiaz\/set_op.py ==================\r\nA \u5e76\u96c6 B :\r\n{1, 2, 3, 4, 5, 7}\r\nA \u4ea4\u96c6 B :\r\n{2, 3}\r\nA - B :\r\n{1, 4}\r\nB - A :\r\n{5, 7}\r\n&gt;&gt;&gt; \r\n<\/code><\/pre>\n<p>\u4eca\u5929\u7684 Python \u96c6\u5408\u6559\u7a0b\u5c31\u5230\u8fd9\u91cc\u3002\u5e0c\u671b\u60a8\u5bf9 Python \u96c6\u5408\u6709\u4e86\u6df1\u5165\u7684\u7406\u89e3\u548c\u638c\u63e1\u3002\u5982\u679c\u60a8\u6709\u4efb\u4f55\u7591\u95ee\uff0c\u8bf7\u5728\u8bc4\u8bba\u533a\u7559\u8a00\uff0c\u6211\u4eec\u4f1a\u5c3d\u5feb\u4e3a\u60a8\u89e3\u7b54\u3002\u53c2\u8003\u8d44\u6599\uff1a<a href=\"https:\/\/docs.python.org\/3\/library\/stdtypes.html#set-types-set-frozenset\" target=\"_blank\" rel=\"noopener\">Python \u5b98\u65b9\u6587\u6863<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python \u96c6\u5408\u8be6\u89e3 Python \u96c6\u5408\uff08Set\uff09\u662f\u4e00\u4e2a\u65e0\u5e8f\u4e14\u5143\u7d20\u552f\u4e00\u7684\u96c6\u5408\u3002\u5f53\u60a8\u9700\u8981\u4ece\u5217\u8868\u4e2d\u63d0\u53d6\u552f\u4e00\u5143\u7d20\uff0c [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[32,823,252,259,551],"class_list":["post-212","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-python","tag-set","tag-252","tag-259","tag-551"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python\u96c6\u5408\uff1a\u6df1\u5165\u7406\u89e3\u6570\u636e\u7ed3\u6784\u4e0e\u9ad8\u6548\u5e94\u7528 - Blog - Silicon Cloud<\/title>\n<meta name=\"description\" content=\"\u63a2\u7d22Python\u96c6\u5408\uff08Set\uff09\u7684\u5f3a\u5927\u529f\u80fd\u4e0e\u5e94\u7528\u573a\u666f\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u96c6\u5408\u7684\u521b\u5efa\u3001\u57fa\u672c\u64cd\u4f5c\u3001\u6570\u5b66\u8fd0\u7b97\u4ee5\u53ca\u5728\u6570\u636e\u53bb\u91cd\u3001\u6210\u5458\u6d4b\u8bd5\u7b49\u65b9\u9762\u7684\u6548\u7387\u4f18\u52bf\uff0c\u52a9\u60a8\u66f4\u9ad8\u6548\u5730\u5904\u7406\u6570\u636e\u3002\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/python-\u96c6\u5408\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python\u96c6\u5408\uff1a\u6df1\u5165\u7406\u89e3\u6570\u636e\u7ed3\u6784\u4e0e\u9ad8\u6548\u5e94\u7528\" \/>\n<meta property=\"og:description\" content=\"\u63a2\u7d22Python\u96c6\u5408\uff08Set\uff09\u7684\u5f3a\u5927\u529f\u80fd\u4e0e\u5e94\u7528\u573a\u666f\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u96c6\u5408\u7684\u521b\u5efa\u3001\u57fa\u672c\u64cd\u4f5c\u3001\u6570\u5b66\u8fd0\u7b97\u4ee5\u53ca\u5728\u6570\u636e\u53bb\u91cd\u3001\u6210\u5458\u6d4b\u8bd5\u7b49\u65b9\u9762\u7684\u6548\u7387\u4f18\u52bf\uff0c\u52a9\u60a8\u66f4\u9ad8\u6548\u5730\u5904\u7406\u6570\u636e\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/python-\u96c6\u5408\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-11-07T00:11:55+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-07-31T18:27:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/6564792ea4b2f92e6c72b016\/0-0.jpg\" \/>\n<meta name=\"author\" content=\"\u97f5, \u79d1\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u97f5, \u79d1\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/python-%e9%9b%86%e5%90%88\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/python-%e9%9b%86%e5%90%88\/\",\"name\":\"Python\u96c6\u5408\uff1a\u6df1\u5165\u7406\u89e3\u6570\u636e\u7ed3\u6784\u4e0e\u9ad8\u6548\u5e94\u7528 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-11-07T00:11:55+00:00\",\"dateModified\":\"2025-07-31T18:27:54+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/6530331a63adef3b3443a1fab53a0e6e\"},\"description\":\"\u63a2\u7d22Python\u96c6\u5408\uff08Set\uff09\u7684\u5f3a\u5927\u529f\u80fd\u4e0e\u5e94\u7528\u573a\u666f\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u96c6\u5408\u7684\u521b\u5efa\u3001\u57fa\u672c\u64cd\u4f5c\u3001\u6570\u5b66\u8fd0\u7b97\u4ee5\u53ca\u5728\u6570\u636e\u53bb\u91cd\u3001\u6210\u5458\u6d4b\u8bd5\u7b49\u65b9\u9762\u7684\u6548\u7387\u4f18\u52bf\uff0c\u52a9\u60a8\u66f4\u9ad8\u6548\u5730\u5904\u7406\u6570\u636e\u3002\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/python-%e9%9b%86%e5%90%88\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/python-%e9%9b%86%e5%90%88\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/python-%e9%9b%86%e5%90%88\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python\u96c6\u5408\uff1a\u6df1\u5165\u7406\u89e3\u6570\u636e\u7ed3\u6784\u4e0e\u9ad8\u6548\u5e94\u7528\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/6530331a63adef3b3443a1fab53a0e6e\",\"name\":\"\u97f5, \u79d1\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/429ccb39b3fff5188bc17986222cfb0936cbadb8cc933cff04ab5ca01bd30a08?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/429ccb39b3fff5188bc17986222cfb0936cbadb8cc933cff04ab5ca01bd30a08?s=96&d=mm&r=g\",\"caption\":\"\u97f5, \u79d1\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/yunke\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/python-%e9%9b%86%e5%90%88\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Python\u96c6\u5408\uff1a\u6df1\u5165\u7406\u89e3\u6570\u636e\u7ed3\u6784\u4e0e\u9ad8\u6548\u5e94\u7528 - Blog - Silicon Cloud","description":"\u63a2\u7d22Python\u96c6\u5408\uff08Set\uff09\u7684\u5f3a\u5927\u529f\u80fd\u4e0e\u5e94\u7528\u573a\u666f\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u96c6\u5408\u7684\u521b\u5efa\u3001\u57fa\u672c\u64cd\u4f5c\u3001\u6570\u5b66\u8fd0\u7b97\u4ee5\u53ca\u5728\u6570\u636e\u53bb\u91cd\u3001\u6210\u5458\u6d4b\u8bd5\u7b49\u65b9\u9762\u7684\u6548\u7387\u4f18\u52bf\uff0c\u52a9\u60a8\u66f4\u9ad8\u6548\u5730\u5904\u7406\u6570\u636e\u3002","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/python-\u96c6\u5408\/","og_locale":"zh_CN","og_type":"article","og_title":"Python\u96c6\u5408\uff1a\u6df1\u5165\u7406\u89e3\u6570\u636e\u7ed3\u6784\u4e0e\u9ad8\u6548\u5e94\u7528","og_description":"\u63a2\u7d22Python\u96c6\u5408\uff08Set\uff09\u7684\u5f3a\u5927\u529f\u80fd\u4e0e\u5e94\u7528\u573a\u666f\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u96c6\u5408\u7684\u521b\u5efa\u3001\u57fa\u672c\u64cd\u4f5c\u3001\u6570\u5b66\u8fd0\u7b97\u4ee5\u53ca\u5728\u6570\u636e\u53bb\u91cd\u3001\u6210\u5458\u6d4b\u8bd5\u7b49\u65b9\u9762\u7684\u6548\u7387\u4f18\u52bf\uff0c\u52a9\u60a8\u66f4\u9ad8\u6548\u5730\u5904\u7406\u6570\u636e\u3002","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/python-\u96c6\u5408\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-11-07T00:11:55+00:00","article_modified_time":"2025-07-31T18:27:54+00:00","og_image":[{"url":"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/6564792ea4b2f92e6c72b016\/0-0.jpg"}],"author":"\u97f5, \u79d1","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u97f5, \u79d1","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/python-%e9%9b%86%e5%90%88\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/python-%e9%9b%86%e5%90%88\/","name":"Python\u96c6\u5408\uff1a\u6df1\u5165\u7406\u89e3\u6570\u636e\u7ed3\u6784\u4e0e\u9ad8\u6548\u5e94\u7528 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-11-07T00:11:55+00:00","dateModified":"2025-07-31T18:27:54+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/6530331a63adef3b3443a1fab53a0e6e"},"description":"\u63a2\u7d22Python\u96c6\u5408\uff08Set\uff09\u7684\u5f3a\u5927\u529f\u80fd\u4e0e\u5e94\u7528\u573a\u666f\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u96c6\u5408\u7684\u521b\u5efa\u3001\u57fa\u672c\u64cd\u4f5c\u3001\u6570\u5b66\u8fd0\u7b97\u4ee5\u53ca\u5728\u6570\u636e\u53bb\u91cd\u3001\u6210\u5458\u6d4b\u8bd5\u7b49\u65b9\u9762\u7684\u6548\u7387\u4f18\u52bf\uff0c\u52a9\u60a8\u66f4\u9ad8\u6548\u5730\u5904\u7406\u6570\u636e\u3002","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/python-%e9%9b%86%e5%90%88\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/python-%e9%9b%86%e5%90%88\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/python-%e9%9b%86%e5%90%88\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"Python\u96c6\u5408\uff1a\u6df1\u5165\u7406\u89e3\u6570\u636e\u7ed3\u6784\u4e0e\u9ad8\u6548\u5e94\u7528"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/6530331a63adef3b3443a1fab53a0e6e","name":"\u97f5, \u79d1","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/429ccb39b3fff5188bc17986222cfb0936cbadb8cc933cff04ab5ca01bd30a08?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/429ccb39b3fff5188bc17986222cfb0936cbadb8cc933cff04ab5ca01bd30a08?s=96&d=mm&r=g","caption":"\u97f5, \u79d1"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/yunke\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/python-%e9%9b%86%e5%90%88\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/212","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=212"}],"version-history":[{"count":3,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/212\/revisions"}],"predecessor-version":[{"id":109692,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/212\/revisions\/109692"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=212"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}