{"id":170,"date":"2026-03-30T22:24:39","date_gmt":"2026-03-30T14:24:39","guid":{"rendered":"https:\/\/blog.mumudlin.com\/?p=170"},"modified":"2026-03-31T10:24:23","modified_gmt":"2026-03-31T02:24:23","slug":"symbols_and_annotations","status":"publish","type":"post","link":"https:\/\/blog.mumudlin.com\/index.php\/symbols_and_annotations\/","title":{"rendered":"\u53d8\u91cf\u3001\u7b26\u53f7\u4e0e\u6ce8\u91ca"},"content":{"rendered":"<h3>Python \u57fa\u7840\u6838\u5fc3\uff1a\u6570\u636e\u7c7b\u578b\u4e0e\u7b26\u53f7\u89c4\u8303<\/h3>\n<p>\u5728\u7f16\u7a0b\u7684\u4e16\u754c\u91cc\uff0c\u6570\u636e\u7c7b\u578b\u5b9a\u4e49\u4e86\u201c\u6211\u4eec\u5904\u7406\u4ec0\u4e48\u201d\uff0c\u800c\u7b26\u53f7\u5219\u5b9a\u4e49\u4e86\u201c\u6211\u4eec\u5982\u4f55\u64cd\u4f5c\u201d\u3002\u7406\u89e3 Python \u7684\u57fa\u672c\u6570\u636e\u7c7b\u578b\u4ee5\u53ca\u4e25\u683c\u9075\u5b88\u7b26\u53f7\u89c4\u8303\uff0c\u662f\u5199\u51fa\u6b63\u786e\u4ee3\u7801\u7684\u7b2c\u4e00\u6b65\u3002<\/p>\n<h4>1. \u6838\u5fc3\u6570\u636e\u7c7b\u578b<\/h4>\n<p>Python \u662f\u4e00\u79cd\u52a8\u6001\u7c7b\u578b\u8bed\u8a00\uff0c\u8fd9\u610f\u5473\u7740\u4f60\u4e0d\u9700\u8981\u5728\u58f0\u660e\u53d8\u91cf\u65f6\u6307\u5b9a\u7c7b\u578b\uff0cPython \u4f1a\u6839\u636e\u8d4b\u7ed9\u53d8\u91cf\u7684\u503c\u81ea\u52a8\u63a8\u65ad\u5176\u7c7b\u578b\u3002<\/p>\n<p>Python3 \u4e2d\u5e38\u89c1\u7684\u6807\u51c6\u6570\u636e\u7c7b\u578b\u4e3b\u8981\u5206\u4e3a\u4ee5\u4e0b\u51e0\u7c7b\uff1a<\/p>\n<ul>\n<li><strong>Number (\u6570\u5b57)<\/strong>\uff1a\u5305\u62ec <code>int<\/code> (\u6574\u6570)\u3001<code>float<\/code> (\u6d6e\u70b9\u6570)\u3001<code>bool<\/code> (\u5e03\u5c14\u503c) \u548c <code>complex<\/code> (\u590d\u6570)\u3002<\/li>\n<li><strong>String (\u5b57\u7b26\u4e32)<\/strong>\uff1a\u7528\u4e8e\u5b58\u50a8\u6587\u672c\uff0c\u7528\u5355\u5f15\u53f7 <code>&#039;<\/code> \u6216\u53cc\u5f15\u53f7 <code>&quot;<\/code> \u62ec\u8d77\u6765\u3002<\/li>\n<li><strong>List (\u5217\u8868)<\/strong>\uff1a\u6709\u5e8f\u3001\u53ef\u53d8\u7684\u96c6\u5408\uff0c\u53ef\u4ee5\u5b58\u653e\u4e0d\u540c\u7c7b\u578b\u7684\u5143\u7d20\u3002<\/li>\n<li><strong>Tuple (\u5143\u7ec4)<\/strong>\uff1a\u6709\u5e8f\u3001\u4e0d\u53ef\u53d8\u7684\u96c6\u5408\u3002<\/li>\n<li><strong>Set (\u96c6\u5408)<\/strong>\uff1a\u65e0\u5e8f\u3001\u4e0d\u91cd\u590d\u7684\u5143\u7d20\u96c6\u3002<\/li>\n<li><strong>Dictionary (\u5b57\u5178)<\/strong>\uff1a\u65e0\u5e8f\u7684\u952e\u503c\u5bf9\uff08Key-Value\uff09\u96c6\u5408\u3002<\/li>\n<\/ul>\n<p><strong>\u6838\u5fc3\u7279\u6027\uff1a\u53ef\u53d8\u4e0e\u4e0d\u53ef\u53d8<\/strong><\/p>\n<p>\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u6982\u5ff5\u662f\u6570\u636e\u7684<strong>\u53ef\u53d8\u6027<\/strong>\u3002\u8fd9\u51b3\u5b9a\u4e86\u6570\u636e\u5728\u5185\u5b58\u4e2d\u662f\u5982\u4f55\u5b58\u50a8\u548c\u88ab\u4fee\u6539\u7684\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">\u5206\u7c7b<\/th>\n<th style=\"text-align: left;\">\u5305\u542b\u7c7b\u578b<\/th>\n<th style=\"text-align: left;\">\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\"><strong>\u4e0d\u53ef\u53d8\u6570\u636e<\/strong><\/td>\n<td style=\"text-align: left;\"><strong>Number, String, Tuple<\/strong><\/td>\n<td style=\"text-align: left;\">\u4fee\u6539\u53d8\u91cf\u7684\u503c\u65f6\uff0c\u5b9e\u9645\u4e0a\u662f\u521b\u5efa\u4e86\u65b0\u7684\u5bf9\u8c61\uff0c\u539f\u5bf9\u8c61\u4e0d\u53d8\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><strong>\u53ef\u53d8\u6570\u636e<\/strong><\/td>\n<td style=\"text-align: left;\"><strong>List, Dictionary, Set<\/strong><\/td>\n<td style=\"text-align: left;\">\u4fee\u6539\u53d8\u91cf\u7684\u503c\u65f6\uff0c\u662f\u5728\u539f\u5bf9\u8c61\u7684\u57fa\u7840\u4e0a\u8fdb\u884c\u4fee\u6539\uff0c\u5185\u5b58\u5730\u5740\u4fdd\u6301\u4e0d\u53d8\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<blockquote>\n<p><strong>\u63d0\u793a\uff1a<\/strong> \u6b64\u5916\uff0cPython \u8fd8\u652f\u6301\u5982\u5b57\u8282\u6570\u7ec4\uff08<code>bytes<\/code>\uff09\u7b49\u9ad8\u7ea7\u6570\u636e\u7c7b\u578b\uff0c\u5e38\u7528\u4e8e\u5904\u7406\u4e8c\u8fdb\u5236\u6570\u636e\u3002<\/p>\n<\/blockquote>\n<hr \/>\n<h4>2. \u5fc5\u987b\u9075\u5b88\u7684\u7b26\u53f7\u89c4\u8303<\/h4>\n<p>\u5728\u7f16\u7a0b\u4e2d\uff0c\u7b26\u53f7\u4e0d\u4ec5\u4ec5\u662f\u6807\u70b9\uff0c\u5b83\u4eec\u662f\u8bed\u6cd5\u7684\u5173\u952e\u7ec4\u6210\u90e8\u5206\u3002<strong>\u4e00\u4e2a\u6781\u5176\u5e38\u89c1\u4e14\u9690\u853d\u7684\u9519\u8bef\u6765\u6e90\u662f\u4f7f\u7528\u4e86\u4e2d\u6587\u7b26\u53f7\uff08\u5168\u89d2\uff09\u800c\u975e\u82f1\u6587\u7b26\u53f7\uff08\u534a\u89d2\uff09\u3002<\/strong><\/p>\n<p><strong>\u9ec4\u91d1\u6cd5\u5219\uff1a\u6240\u6709\u7f16\u7a0b\u8bed\u8a00\u4e2d\u529f\u80fd\u6027\u7b26\u53f7\uff08\u62ec\u53f7\u3001\u5f15\u53f7\u3001\u8fd0\u7b97\u7b26\u7b49\uff09\u5fc5\u987b\u4f7f\u7528\u82f1\u6587\u7b26\u53f7\u3002<\/strong><\/p>\n<p>\u5982\u679c\u5728\u4ee3\u7801\u4e2d\u8bef\u7528\u4e86\u4e2d\u6587\u7b26\u53f7\uff08\u4f8b\u5982\u4e2d\u6587\u62ec\u53f7 <code>\uff08\uff09<\/code> \u6216\u4e2d\u6587\u5f15\u53f7 <code>\u201c\u201d<\/code>\uff09\uff0c\u89e3\u91ca\u5668\u4f1a\u76f4\u63a5\u62a5\u9519 <code>SyntaxError<\/code>\u3002<\/p>\n<p>\u4e0b\u9762\u4ee5 Python \u4e3a\u4f8b\uff0c\u5c55\u793a\u5e38\u89c1\u7b26\u53f7\u7684\u6b63\u786e\u7528\u6cd5\uff1a<\/p>\n<p><strong>1. \u62ec\u53f7 <code>()<\/code> \u4e0e\u7f29\u8fdb<\/strong><br \/>\n\u62ec\u53f7\u7528\u4e8e\u51fd\u6570\u8c03\u7528\u3001\u5b9a\u4e49\u5143\u7ec4\u4ee5\u53ca\u63a7\u5236\u8fd0\u7b97\u4f18\u5148\u7ea7\u3002Python \u4f7f\u7528\u7f29\u8fdb\u6765\u8868\u793a\u4ee3\u7801\u5757\uff0c\u800c\u4e0d\u662f\u50cf C \u8bed\u8a00\u90a3\u6837\u4f7f\u7528\u82b1\u62ec\u53f7\u3002<\/p>\n<pre><code class=\"language-python\"># \u6b63\u786e\uff1a\u82f1\u6587\u62ec\u53f7\u4e0e\u7f29\u8fdb\nfor i in range(5):  # range() \u662f\u51fd\u6570\u8c03\u7528\n    print(i)        # print \u540e\u7684\u62ec\u53f7\u4e5f\u662f\u82f1\u6587<\/code><\/pre>\n<p><strong>2. \u8d4b\u503c\u7b26\u53f7 <code>=<\/code><\/strong><br \/>\n\u5355\u4e2a\u7b49\u53f7 <code>=<\/code> \u662f<strong>\u8d4b\u503c\u8fd0\u7b97\u7b26<\/strong>\uff0c\u5b83\u7684\u4f5c\u7528\u662f\u5c06\u53f3\u8fb9\u7684\u503c\u201c\u7ed1\u5b9a\u201d\u7ed9\u5de6\u8fb9\u7684\u53d8\u91cf\u540d\u3002<\/p>\n<pre><code class=\"language-python\"># \u6b63\u786e\uff1a\u82f1\u6587\u7b49\u53f7\u7528\u4e8e\u8d4b\u503c\na = 10\nb = 20\nname = &quot;Python&quot;<\/code><\/pre>\n<p><strong>3. \u6bd4\u8f83\u7b26\u53f7 <code>==<\/code><\/strong><br \/>\n\u53cc\u7b49\u53f7 <code>==<\/code> \u662f<strong>\u6bd4\u8f83\u8fd0\u7b97\u7b26<\/strong>\uff0c\u7528\u4e8e\u5224\u65ad\u4e24\u8fb9\u7684\u503c\u662f\u5426\u76f8\u7b49\uff0c\u901a\u5e38\u7528\u4e8e <code>if<\/code> \u6761\u4ef6\u5224\u65ad\u6216\u5faa\u73af\u4e2d\uff0c\u8fd4\u56de\u5e03\u5c14\u503c\uff08<code>True<\/code> \u6216 <code>False<\/code>\uff09\u3002<\/p>\n<pre><code class=\"language-python\"># \u6b63\u786e\uff1a\u53cc\u7b49\u53f7\u7528\u4e8e\u5224\u65ad\na = 10\nb = 10\nprint(a == b)  # \u8f93\u51fa: True\n\nif a == 10:\n    print(&quot;a \u7b49\u4e8e 10&quot;)<\/code><\/pre>\n<p><strong>\u5e38\u89c1\u9519\u8bef\u8b66\u793a\uff1a<\/strong><\/p>\n<ul>\n<li>\u274c <strong>\u9519\u8bef 1<\/strong>\uff1a\u5728\u9700\u8981\u8d4b\u503c\u7684\u5730\u65b9\u7528\u4e86\u53cc\u7b49\u53f7\uff08\u903b\u8f91\u9519\u8bef\uff09\u3002<\/li>\n<li>\u274c <strong>\u9519\u8bef 2<\/strong>\uff1a\u5728\u9700\u8981\u5224\u65ad\u76f8\u7b49\u7684\u5730\u65b9\u7528\u4e86\u5355\u7b49\u53f7\uff08\u8bed\u6cd5\u9519\u8bef\uff0c\u901a\u5e38\u4f1a\u62a5 <code>SyntaxError<\/code> \u6216\u903b\u8f91\u4e0d\u751f\u6548\uff09\u3002<\/li>\n<li>\u274c <strong>\u9519\u8bef 3<\/strong>\uff1a\u4f7f\u7528\u4e86\u4e2d\u6587\u5168\u89d2\u7b26\u53f7 <code>\uff1d<\/code> \u6216 <code>\uff08\uff09<\/code>\uff0c\u5bfc\u81f4\u4ee3\u7801\u65e0\u6cd5\u8fd0\u884c\u3002<\/li>\n<\/ul>\n<hr \/>\n<h4>3. \u603b\u7ed3<\/h4>\n<p>\u638c\u63e1 Python \u7684\u6570\u636e\u7c7b\u578b\u5206\u7c7b\uff08\u7279\u522b\u662f\u53ef\u53d8\u4e0e\u4e0d\u53ef\u53d8\u7684\u533a\u522b\uff09\u4ee5\u53ca\u4e25\u683c\u9075\u5b88\u82f1\u6587\u7b26\u53f7\u7684\u8f93\u5165\u4e60\u60ef\uff0c\u662f\u907f\u514d\u4f4e\u7ea7\u9519\u8bef\u3001\u63d0\u5347\u7f16\u7a0b\u6548\u7387\u7684\u5173\u952e\u3002\u5efa\u8bae\u5728\u7f16\u5199\u4ee3\u7801\u65f6\uff0c\u59cb\u7ec8\u4fdd\u6301\u8f93\u5165\u6cd5\u5904\u4e8e<strong>\u82f1\u6587\u72b6\u6001<\/strong>\u3002<\/p>\n<p><em>\u60f3\u4e86\u89e3\u66f4\u591a\u5173\u4e8e Python \u6570\u636e\u7c7b\u578b\u7684\u8f6c\u6362\u548c\u8be6\u7ec6\u64cd\u4f5c\uff0c\u53ef\u4ee5\u53c2\u8003\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/www.runoob.com\/python3\/python3-data-type.html\">\u83dc\u9e1f\u6559\u7a0b - Python3 \u57fa\u672c\u6570\u636e\u7c7b\u578b<\/a><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python \u57fa\u7840\u6838\u5fc3\uff1a\u6570\u636e\u7c7b\u578b\u4e0e\u7b26\u53f7\u89c4\u8303 \u5728\u7f16\u7a0b\u7684\u4e16\u754c\u91cc\uff0c\u6570\u636e\u7c7b\u578b\u5b9a\u4e49\u4e86\u201c\u6211\u4eec\u5904\u7406\u4ec0\u4e48\u201d\uff0c\u800c\u7b26\u53f7\u5219\u5b9a\u4e49\u4e86\u201c\u6211 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-170","post","type-post","status-publish","format-standard","hentry","category-13"],"_links":{"self":[{"href":"https:\/\/blog.mumudlin.com\/index.php\/wp-json\/wp\/v2\/posts\/170","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.mumudlin.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mumudlin.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mumudlin.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mumudlin.com\/index.php\/wp-json\/wp\/v2\/comments?post=170"}],"version-history":[{"count":3,"href":"https:\/\/blog.mumudlin.com\/index.php\/wp-json\/wp\/v2\/posts\/170\/revisions"}],"predecessor-version":[{"id":197,"href":"https:\/\/blog.mumudlin.com\/index.php\/wp-json\/wp\/v2\/posts\/170\/revisions\/197"}],"wp:attachment":[{"href":"https:\/\/blog.mumudlin.com\/index.php\/wp-json\/wp\/v2\/media?parent=170"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mumudlin.com\/index.php\/wp-json\/wp\/v2\/categories?post=170"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mumudlin.com\/index.php\/wp-json\/wp\/v2\/tags?post=170"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}