{"id":722,"date":"2025-09-25T13:42:48","date_gmt":"2025-09-25T05:42:48","guid":{"rendered":"https:\/\/hueil.top\/?p=722"},"modified":"2025-11-12T22:38:45","modified_gmt":"2025-11-12T14:38:45","slug":"python%e5%9f%ba%e7%a1%80","status":"publish","type":"post","link":"https:\/\/hueil.top\/?p=722","title":{"rendered":"Python\u57fa\u7840"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">\u4e00\uff0c\u6ce8\u91ca<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">\u6ce8\u91ca\u662f\u4ee3\u7801\u4e2d\u7684\u8f85\u52a9\u6027\u6587\u5b57\uff0c\u7528\u4e8e\u6807\u8bc6\u4ee3\u7801\u7684\u542b\u4e49\u548c\u529f\u80fd\uff0c\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u3002\u4e0d\u5f71\u54cd\u7a0b\u5e8f\u7684\u8fd0\u884c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1.\u5355\u884c\u6ce8\u91ca<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code># \u8fd9\u662f\u4e00\u884c\u5355\u884c\u6ce8\u91ca<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">2.\u591a\u884c\u6ce8\u91ca<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\"\"\"\n \u5728\u8fd9\u91cc\u7684\u90fd\u662f\u6ce8\u91ca\n\"\"\"<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">\u4e8c\uff0c\u6570\u636e\u7c7b\u578b<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">1.\u6570\u5b57\u7c7b\u578b<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u6570\u5b57\u7c7b\u578b\u5206\u4e3a\u6574\u6570\u7c7b\u578bint\uff0c\u6d6e\u70b9\u578bfloat,\u590d\u6570\u7c7b\u578bcomplex\u548c\u5e03\u5c14\u7c7b\u578bbool.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2.\u5b57\u7b26\u4e32\u7c7b\u578b<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>'char'\n\"String\"\n'''shang'''<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u7528\u4e8e\u8868\u793a\u6587\u672c\u6570\u636e\uff0c\u7531\u5355\u5f15\u53f7\uff0c\u53cc\u5f15\u53f7\u6216\u8005\u4e09\u5f15\u53f7\u5305\u542b\u7684\u4e00\u7cfb\u5217\u5b57\u7b26.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u4e09\uff0c\u8fd0\u7b97\u7b26<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">1.\u7b97\u672f\u8fd0\u7b97\u7b26<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b97\u6570\u8fd0\u7b97\u7b26\u4e3b\u8981\u6267\u884c\u57fa\u672c\u7684\u6570\u5b66\u8fd0\u7b97,\u6bd4\u5982\u52a0\uff0c\u51cf\uff0c\u4e58\uff0c\u9664\u7b49\u3002Python\u4e2d\u63d0\u4f9b\u7684\u7b97\u6570\u8fd0\u7b97\u7b26\u5305\u62ec+,-\uff0c*\uff0c\/\uff0c\/\/\uff0c%\uff0c**\uff0c\u5b83\u4eec\u90fd\u662f\u53cc\u76ee\u8fd0\u7b97\u7b26\uff0c\u53ef\u4ee5\u5bf9\u4e24\u4e2a\u64cd\u4f5c\u6570\u8fdb\u884c\u6570\u5b66\u8fd0\u7b97\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2.\u8d4b\u503c\u8fd0\u7b97\u7b26<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">=\u662f\u57fa\u672c\u7684\u8d4b\u503c\u8fd0\u7b97\u7b26\uff0cPython\u5728\u6b64\u57fa\u7840\u4e0a\u8fd8\u6709\u590d\u5408\u8d4b\u503c\u8fd0\u7b97\u7b26\uff0c\u5305\u62ec+=,-=,*=,\/=,\/\/=,%=,**=\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3.\u6bd4\u8f83\u8fd0\u7b97\u7b26<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u6bd4\u8f83\u8fd0\u7b97\u7b26\u53c8\u79f0\u5173\u7cfb\u8fd0\u7b97\u7b26\uff0c\u7528\u4e8e\u6bd4\u8f83\u4e24\u8fb9\u64cd\u4f5c\u6570\u3002Python\u4e2d\u7684\u6bd4\u8f83\u8fd0\u7b97\u7b26\u5305\u62ec==,!=,&gt;,&lt;,&gt;=,&lt;=\u3002\u5b83\u4eec\u901a\u5e38\u7528\u4e8e\u5e03\u5c14\u6d4b\u8bd5\uff0c\u7ed3\u679c\u53ea\u80fd\u662fTrue\u6216False\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4.\u903b\u8f91\u8fd0\u7b97\u7b26<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u903b\u8f91\u8fd0\u7b97\u7b26\u53ef\u4ee5\u5c06\u591a\u4e2a\u6761\u4ef6\u6309\u7167\u903b\u8f91\u8fdb\u884c\u8fde\u63a5\uff0c\u53d8\u6210\u66f4\u590d\u6742\u7684\u6761\u4ef6\uff0cPython\u63d0\u4f9b\u4e86and,or,not\u4e09\u4e2a\u5173\u952e\u5b57\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5.\u6210\u5458\u8fd0\u7b97\u7b26<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u6210\u5458\u8fd0\u7b97\u7b26\u7528\u4e8e\u68c0\u6d4b\u7ed9\u5b9a\u6570\u636e\u662f\u5426\u5b58\u5728\u4e8e\u5b57\u7b26\u4e32\uff0c\u5217\u8868\uff0c\u5143\u7ec4\uff0c\u96c6\u5408\uff0c\u5b57\u5178\u4e2d\uff0c\u5173\u952e\u5b57\u6709in\u548cnot in\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">6.\u4f4d\u8fd0\u7b97\u7b26<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f4d\u8fd0\u7b97\u7b26\u7528\u4e8e\u5bf9\u64cd\u4f5c\u6570\u7684\u4e8c\u8fdb\u5236\u4f4d\u8fdb\u884c\u903b\u8f91\u8fd0\u7b97\uff0c\u64cd\u4f5c\u6570\u5fc5\u987b\u662f\u6574\u6570\u3002Python\u4e2d\u63d0\u4f9b\u4e866\u4e2a\u4f4d\u8fd0\u7b97\u7b26\uff0c\u5206\u522b\u662f&lt;&lt;,&gt;&gt;,&amp;,|,^,~.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u56db\uff0c\u5e38\u89c1\u51fd\u6570<\/h1>\n\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper' data-fancybox='post-images' href='https:\/\/hueil.top\/wp-content\/uploads\/2025\/09\/\u56fe\u7247-1024x845.png'><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"845\" src=\"https:\/\/hueil.top\/wp-content\/uploads\/2025\/09\/\u56fe\u7247-1024x845.png\" alt=\"\" class=\"wp-image-819\" srcset=\"https:\/\/hueil.top\/wp-content\/uploads\/2025\/09\/\u56fe\u7247-1024x845.png 1024w, https:\/\/hueil.top\/wp-content\/uploads\/2025\/09\/\u56fe\u7247-300x248.png 300w, https:\/\/hueil.top\/wp-content\/uploads\/2025\/09\/\u56fe\u7247-768x634.png 768w, https:\/\/hueil.top\/wp-content\/uploads\/2025\/09\/\u56fe\u7247.png 1032w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/div><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Python\u6570\u5b66\u51fd\u6570<\/h3>\n\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper' data-fancybox='post-images' href='https:\/\/hueil.top\/wp-content\/uploads\/2025\/09\/\u56fe\u7247-1-1024x775.png'><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"775\" src=\"https:\/\/hueil.top\/wp-content\/uploads\/2025\/09\/\u56fe\u7247-1-1024x775.png\" alt=\"\" class=\"wp-image-827\" srcset=\"https:\/\/hueil.top\/wp-content\/uploads\/2025\/09\/\u56fe\u7247-1-1024x775.png 1024w, https:\/\/hueil.top\/wp-content\/uploads\/2025\/09\/\u56fe\u7247-1-300x227.png 300w, https:\/\/hueil.top\/wp-content\/uploads\/2025\/09\/\u56fe\u7247-1-768x581.png 768w, https:\/\/hueil.top\/wp-content\/uploads\/2025\/09\/\u56fe\u7247-1.png 1047w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/div><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Python\u968f\u673a\u6570\u51fd\u6570<\/h3>\n\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper' data-fancybox='post-images' href='https:\/\/hueil.top\/wp-content\/uploads\/2025\/09\/\u56fe\u7247-2-1024x390.png'><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"390\" src=\"https:\/\/hueil.top\/wp-content\/uploads\/2025\/09\/\u56fe\u7247-2-1024x390.png\" alt=\"\" class=\"wp-image-829\" srcset=\"https:\/\/hueil.top\/wp-content\/uploads\/2025\/09\/\u56fe\u7247-2-1024x390.png 1024w, https:\/\/hueil.top\/wp-content\/uploads\/2025\/09\/\u56fe\u7247-2-300x114.png 300w, https:\/\/hueil.top\/wp-content\/uploads\/2025\/09\/\u56fe\u7247-2-768x293.png 768w, https:\/\/hueil.top\/wp-content\/uploads\/2025\/09\/\u56fe\u7247-2.png 1136w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/div><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Python\u4e09\u89d2\u51fd\u6570<\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper' data-fancybox='post-images' href='https:\/\/hueil.top\/wp-content\/uploads\/2025\/09\/\u56fe\u7247-4.png'><img loading=\"lazy\" decoding=\"async\" width=\"842\" height=\"574\" src=\"https:\/\/hueil.top\/wp-content\/uploads\/2025\/09\/\u56fe\u7247-4.png\" alt=\"\" class=\"wp-image-832\" srcset=\"https:\/\/hueil.top\/wp-content\/uploads\/2025\/09\/\u56fe\u7247-4.png 842w, https:\/\/hueil.top\/wp-content\/uploads\/2025\/09\/\u56fe\u7247-4-300x205.png 300w, https:\/\/hueil.top\/wp-content\/uploads\/2025\/09\/\u56fe\u7247-4-768x524.png 768w\" sizes=\"auto, (max-width: 842px) 100vw, 842px\" \/><\/div><\/figure>\n\n\n\n<h1 class=\"wp-block-heading\">\u4e94\uff0c\u8bed\u6cd5\u683c\u5f0f<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">1.if\u8bed\u53e5<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Python\u6761\u4ef6\u8bed\u53e5\u662f\u901a\u8fc7\u4e00\u6761\u6216\u591a\u6761\u8bed\u53e5\u7684\u6267\u884c\u7ed3\u679c\uff08True\u6216\u8005False\uff09\u6765\u51b3\u5b9a\u6267\u884c\u7684\u4ee3\u7801\u5757<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Python\u7a0b\u5e8f\u8bed\u8a00\u6307\u5b9a\u4efb\u4f55\u975e0\u548c\u975e\u7a7a\uff08null\uff09\u503c\u4e3atrue\uff0c0 \u6216\u8005 null\u4e3afalse\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if \u5224\u65ad\u6761\u4ef6:\n    \u6267\u884c\u8bed\u53e5\u2026\u2026\nelif: \u5224\u65ad\u6761\u4ef6:\n    \u6267\u884c\u8bed\u53e5\u2026\u2026\nelse:\n    \u6267\u884c\u8bed\u53e5\u2026\u2026\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">2.\u5faa\u73af\u8bed\u53e5<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Python \u63d0\u4f9b\u4e86 for \u5faa\u73af\u548c while \u5faa\u73af<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">While\u5faa\u73af<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">While\u5faa\u73af\u5f53\u5224\u65ad\u6761\u4ef6\u5047 false \u65f6\uff0c\u5faa\u73af\u7ed3\u675f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>count = 0\nwhile count &lt; 5:\n   print\uff08count, \" is  less than 5\"\uff09\n   count = count + 1\n   break\nelse:\n   print\uff08count, \" is not less than 5\"\uff09<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">For\u5faa\u73af<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">for\u5faa\u73af\u53ef\u4ee5\u904d\u5386\u4efb\u4f55\u5e8f\u5217\u7684\u9879\u76ee\uff0c\u5982\u4e00\u4e2a\u5217\u8868\u6216\u8005\u4e00\u4e2a\u5b57\u7b26\u4e32<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/usr\/bin\/python\n# -*- coding: UTF-8 -*-\n \nfor num in range(10,20):  # \u8fed\u4ee3 10 \u5230 20 (\u4e0d\u5305\u542b) \u4e4b\u95f4\u7684\u6570\u5b57\n   for i in range(2,num): # \u6839\u636e\u56e0\u5b50\u8fed\u4ee3\n      if num%i == 0:      # \u786e\u5b9a\u7b2c\u4e00\u4e2a\u56e0\u5b50\n         j=num\/i          # \u8ba1\u7b97\u7b2c\u4e8c\u4e2a\u56e0\u5b50\n         print ('%d \u7b49\u4e8e %d * %d' % (num,i,j))\n         break            # \u8df3\u51fa\u5f53\u524d\u5faa\u73af\n   else:                  # \u5faa\u73af\u7684 else \u90e8\u5206\n      print ('%d \u662f\u4e00\u4e2a\u8d28\u6570' % num)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">3.\u5176\u4ed6\u8bed\u53e5<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">break<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">break\u8bed\u53e5\u7528\u6765\u7ec8\u6b62\u5faa\u73af\u8bed\u53e5\uff0c\u5373\u5faa\u73af\u6761\u4ef6\u6ca1\u6709False\u6761\u4ef6\u6216\u8005\u5e8f\u5217\u8fd8\u6ca1\u88ab\u5b8c\u5168\u9012\u5f52\u5b8c\uff0c\u4e5f\u4f1a\u505c\u6b62\u6267\u884c\u5faa\u73af\u8bed\u53e5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/usr\/bin\/python\n# -*- coding: UTF-8 -*-\n \nfor letter in 'Python':     # \u7b2c\u4e00\u4e2a\u5b9e\u4f8b\n   if letter == 'h':\n      break\n   print ('\u5f53\u524d\u5b57\u6bcd :', letter)\n  \nvar = 10                    # \u7b2c\u4e8c\u4e2a\u5b9e\u4f8b\nwhile var > 0:              \n   print( '\u5f53\u524d\u53d8\u91cf\u503c :', var)\n   var = var -1\n   if var == 5:   # \u5f53\u53d8\u91cf var \u7b49\u4e8e 5 \u65f6\u9000\u51fa\u5faa\u73af\n      break\n \nprint (\"Good bye!\")<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">continue<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">continue \u8bed\u53e5\u7528\u6765\u544a\u8bc9Python\u8df3\u8fc7\u5f53\u524d\u5faa\u73af\u7684\u5269\u4f59\u8bed\u53e5\uff0c\u7136\u540e\u7ee7\u7eed\u8fdb\u884c\u4e0b\u4e00\u8f6e\u5faa\u73af\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/usr\/bin\/python\n# -*- coding: UTF-8 -*-\n \nfor letter in 'Python':     # \u7b2c\u4e00\u4e2a\u5b9e\u4f8b\n   if letter == 'h':\n      continue\n   print ('\u5f53\u524d\u5b57\u6bcd :', letter)\n \nvar = 10                    # \u7b2c\u4e8c\u4e2a\u5b9e\u4f8b\nwhile var > 0:              \n   var = var -1\n   if var == 5:\n      continue\n   print ('\u5f53\u524d\u53d8\u91cf\u503c :', var)\nprint (\"Good bye!\")<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u7c7b\u578b\u8f6c\u6362<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>int(x &#91;,base ])         \u5c06x\u8f6c\u6362\u4e3a\u4e00\u4e2a\u6574\u6570  \nlong(x &#91;,base ])        \u5c06x\u8f6c\u6362\u4e3a\u4e00\u4e2a\u957f\u6574\u6570  \nfloat(x )               \u5c06x\u8f6c\u6362\u5230\u4e00\u4e2a\u6d6e\u70b9\u6570  \ncomplex(real &#91;,imag ])  \u521b\u5efa\u4e00\u4e2a\u590d\u6570  \nstr(x )                 \u5c06\u5bf9\u8c61 x \u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32  \nrepr(x )                \u5c06\u5bf9\u8c61 x \u8f6c\u6362\u4e3a\u8868\u8fbe\u5f0f\u5b57\u7b26\u4e32  \neval(str )              \u7528\u6765\u8ba1\u7b97\u5728\u5b57\u7b26\u4e32\u4e2d\u7684\u6709\u6548Python\u8868\u8fbe\u5f0f,\u5e76\u8fd4\u56de\u4e00\u4e2a\u5bf9\u8c61  \ntuple(s )               \u5c06\u5e8f\u5217 s \u8f6c\u6362\u4e3a\u4e00\u4e2a\u5143\u7ec4  \nlist(s )                \u5c06\u5e8f\u5217 s \u8f6c\u6362\u4e3a\u4e00\u4e2a\u5217\u8868  \nchr(x )                 \u5c06\u4e00\u4e2a\u6574\u6570\u8f6c\u6362\u4e3a\u4e00\u4e2a\u5b57\u7b26  \nunichr(x )              \u5c06\u4e00\u4e2a\u6574\u6570\u8f6c\u6362\u4e3aUnicode\u5b57\u7b26  \nord(x )                 \u5c06\u4e00\u4e2a\u5b57\u7b26\u8f6c\u6362\u4e3a\u5b83\u7684\u6574\u6570\u503c  \nhex(x )                 \u5c06\u4e00\u4e2a\u6574\u6570\u8f6c\u6362\u4e3a\u4e00\u4e2a\u5341\u516d\u8fdb\u5236\u5b57\u7b26\u4e32  \noct(x )                 \u5c06\u4e00\u4e2a\u6574\u6570\u8f6c\u6362\u4e3a\u4e00\u4e2a\u516b\u8fdb\u5236\u5b57\u7b26\u4e32  \n<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">\u516d\uff0c\u7ec4\u5408\u6570\u636e\u7c7b\u578b<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">1.\u96c6\u5408<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>{\u201dred\u201c\uff0c\u201dblue\u201c\uff0c1}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u96c6\u5408\u7c7b\u578b\u53ef\u4ee5\u4fdd\u5b58\u4efb\u610f\u6570\u91cf\uff0c\u7c7b\u578b\u7684\u5143\u7d20\uff0c\u6ca1\u6709\u7279\u5b9a\u7684\u987a\u5e8f\uff0c\u6bcf\u4e2a\u5143\u7d20\u5fc5\u987b\u552f\u4e00\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2.\u5217\u8868<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;1,2,\"list\"]<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5217\u8868\u53ef\u4ee5\u4fdd\u5b58\u4efb\u610f\u6570\u91cf\uff0c\u4efb\u610f\u7c7b\u578b\u7684\u5143\u7d20\uff0c\u8fd9\u4e9b\u5143\u7d20\u6709\u987a\u5e8f\uff0c\u53ef\u91cd\u590d\uff0c\u53ef\u4fee\u6539\u4e3a\u5176\u4ed6\u5143\u7d20\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3.\u5143\u7ec4<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>(1,2,\"apple\")<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5143\u7ec4\u7c7b\u578b\u4e0e\u5217\u8868\u4f5c\u7528\u7c7b\u4f3c\uff0c\u5b83\u4e5f\u53ef\u4ee5\u4fdd\u5b58\u4efb\u610f\u6570\u91cf\uff0c\u4efb\u610f\u7c7b\u578b\u7684\u5143\u7d20\uff0c\u6709\u987a\u5e8f\uff0c\u53ef\u91cd\u590d\uff0c\u4f46\u662f\u4e0d\u80fd\u4fee\u6539\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4.\u5b57\u5178<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>{\"name\":\"\u5f20\u4e09\",\"age\":18}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u53ef\u4ee5\u4fdd\u5b58\u4efb\u610f\u6570\u91cf\u7684\u5143\u7d20\uff0c\u7528\u201dKey:Value\u201c\u7684\u683c\u5f0f<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u4e03\uff0c\u81ea\u5b9a\u4e49\u51fd\u6570<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">1.\u5b9a\u4e49\u683c\u5f0f<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/usr\/bin\/python\n# -*- coding: UTF-8 -*-\n \ntotal = 0 # \u8fd9\u662f\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf\n# \u53ef\u5199\u51fd\u6570\u8bf4\u660e\ndef sum( arg1, arg2 ):\n   #\u8fd4\u56de2\u4e2a\u53c2\u6570\u7684\u548c.\"\n   total = arg1 + arg2 # total\u5728\u8fd9\u91cc\u662f\u5c40\u90e8\u53d8\u91cf.\n   print (\"\u51fd\u6570\u5185\u662f\u5c40\u90e8\u53d8\u91cf : \", total)\n   return total\n \n#\u8c03\u7528sum\u51fd\u6570\nsum( 10, 20 )\nprint (\"\u51fd\u6570\u5916\u662f\u5168\u5c40\u53d8\u91cf : \", total)<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\uff0c\u6ce8\u91ca \u6ce8\u91ca\u662f\u4ee3\u7801\u4e2d\u7684\u8f85\u52a9\u6027\u6587\u5b57\uff0c\u7528\u4e8e\u6807\u8bc6\u4ee3\u7801\u7684\u542b\u4e49\u548c\u529f\u80fd\uff0c\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u3002\u4e0d\u5f71\u54cd\u7a0b\u5e8f\u7684\u8fd0\u884c\u3002 1.\u5355\u884c\u6ce8 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":851,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28],"tags":[5,21],"class_list":["post-722","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-python","tag-21"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python\u57fa\u7840 - Hueil\u306e\u5c0f\u7a9d<\/title>\n<meta name=\"description\" content=\"\u8ba1\u7b97\u673a\u5e94\u7528\uff0cPython\uff0cJava\uff0c\u4fe1\u606f\u5b89\u5168\uff0c\u7f51\u7ad9\u7f8e\u5316,\u7269\u8054\u7f51\uff0cC\/C++\u7b97\u6cd5\u5206\u6790,\u7f51\u7ad9\u5b9e\u6218\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/hueil.top\/?p=722\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python\u57fa\u7840 - Hueil\u306e\u5c0f\u7a9d\" \/>\n<meta property=\"og:description\" content=\"\u8ba1\u7b97\u673a\u5e94\u7528\uff0cPython\uff0cJava\uff0c\u4fe1\u606f\u5b89\u5168\uff0c\u7f51\u7ad9\u7f8e\u5316,\u7269\u8054\u7f51\uff0cC\/C++\u7b97\u6cd5\u5206\u6790,\u7f51\u7ad9\u5b9e\u6218\" \/>\n<meta property=\"og:url\" content=\"https:\/\/hueil.top\/?p=722\" \/>\n<meta property=\"og:site_name\" content=\"Hueil\u306e\u5c0f\u7a9d\" \/>\n<meta property=\"article:published_time\" content=\"2025-09-25T05:42:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-11-12T14:38:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/hueil.top\/wp-content\/uploads\/2025\/10\/78b810f902ae25bada3326b5ec0f6d73.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1026\" \/>\n\t<meta property=\"og:image:height\" content=\"1022\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"\u5c0f\u5f20\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u5c0f\u5f20\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/hueil.top\/?p=722#article\",\"isPartOf\":{\"@id\":\"https:\/\/hueil.top\/?p=722\"},\"author\":{\"name\":\"\u5c0f\u5f20\",\"@id\":\"https:\/\/hueil.top\/#\/schema\/person\/b3ed2232564570b957865ad1cefe7b88\"},\"headline\":\"Python\u57fa\u7840\",\"datePublished\":\"2025-09-25T05:42:48+00:00\",\"dateModified\":\"2025-11-12T14:38:45+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/hueil.top\/?p=722\"},\"wordCount\":57,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/hueil.top\/#\/schema\/person\/b3ed2232564570b957865ad1cefe7b88\"},\"image\":{\"@id\":\"https:\/\/hueil.top\/?p=722#primaryimage\"},\"thumbnailUrl\":\"https:\/\/hueil.top\/wp-content\/uploads\/2025\/10\/78b810f902ae25bada3326b5ec0f6d73.webp\",\"keywords\":[\"Python\",\"\u7b97\u6cd5\u5206\u6790\"],\"articleSection\":[\"Python\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/hueil.top\/?p=722#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/hueil.top\/?p=722\",\"url\":\"https:\/\/hueil.top\/?p=722\",\"name\":\"Python\u57fa\u7840 - Hueil\u306e\u5c0f\u7a9d\",\"isPartOf\":{\"@id\":\"https:\/\/hueil.top\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/hueil.top\/?p=722#primaryimage\"},\"image\":{\"@id\":\"https:\/\/hueil.top\/?p=722#primaryimage\"},\"thumbnailUrl\":\"https:\/\/hueil.top\/wp-content\/uploads\/2025\/10\/78b810f902ae25bada3326b5ec0f6d73.webp\",\"datePublished\":\"2025-09-25T05:42:48+00:00\",\"dateModified\":\"2025-11-12T14:38:45+00:00\",\"description\":\"\u8ba1\u7b97\u673a\u5e94\u7528\uff0cPython\uff0cJava\uff0c\u4fe1\u606f\u5b89\u5168\uff0c\u7f51\u7ad9\u7f8e\u5316,\u7269\u8054\u7f51\uff0cC\/C++\u7b97\u6cd5\u5206\u6790,\u7f51\u7ad9\u5b9e\u6218\",\"breadcrumb\":{\"@id\":\"https:\/\/hueil.top\/?p=722#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/hueil.top\/?p=722\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/hueil.top\/?p=722#primaryimage\",\"url\":\"https:\/\/hueil.top\/wp-content\/uploads\/2025\/10\/78b810f902ae25bada3326b5ec0f6d73.webp\",\"contentUrl\":\"https:\/\/hueil.top\/wp-content\/uploads\/2025\/10\/78b810f902ae25bada3326b5ec0f6d73.webp\",\"width\":1026,\"height\":1022},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/hueil.top\/?p=722#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/hueil.top\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python\u57fa\u7840\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/hueil.top\/#website\",\"url\":\"https:\/\/hueil.top\/\",\"name\":\"Hueil\u306e\u5c0f\u7a9d\",\"description\":\"Hueil\u7684\u5c0f\u7834\u7ad9\",\"publisher\":{\"@id\":\"https:\/\/hueil.top\/#\/schema\/person\/b3ed2232564570b957865ad1cefe7b88\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/hueil.top\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/hueil.top\/#\/schema\/person\/b3ed2232564570b957865ad1cefe7b88\",\"name\":\"\u5c0f\u5f20\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/hueil.top\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/hueil.top\/wp-content\/uploads\/2025\/08\/Hueil.jpg\",\"contentUrl\":\"https:\/\/hueil.top\/wp-content\/uploads\/2025\/08\/Hueil.jpg\",\"width\":940,\"height\":940,\"caption\":\"\u5c0f\u5f20\"},\"logo\":{\"@id\":\"https:\/\/hueil.top\/#\/schema\/person\/image\/\"},\"sameAs\":[\"https:\/\/hueil.top\"],\"url\":\"https:\/\/hueil.top\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python\u57fa\u7840 - Hueil\u306e\u5c0f\u7a9d","description":"\u8ba1\u7b97\u673a\u5e94\u7528\uff0cPython\uff0cJava\uff0c\u4fe1\u606f\u5b89\u5168\uff0c\u7f51\u7ad9\u7f8e\u5316,\u7269\u8054\u7f51\uff0cC\/C++\u7b97\u6cd5\u5206\u6790,\u7f51\u7ad9\u5b9e\u6218","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:\/\/hueil.top\/?p=722","og_locale":"zh_CN","og_type":"article","og_title":"Python\u57fa\u7840 - Hueil\u306e\u5c0f\u7a9d","og_description":"\u8ba1\u7b97\u673a\u5e94\u7528\uff0cPython\uff0cJava\uff0c\u4fe1\u606f\u5b89\u5168\uff0c\u7f51\u7ad9\u7f8e\u5316,\u7269\u8054\u7f51\uff0cC\/C++\u7b97\u6cd5\u5206\u6790,\u7f51\u7ad9\u5b9e\u6218","og_url":"https:\/\/hueil.top\/?p=722","og_site_name":"Hueil\u306e\u5c0f\u7a9d","article_published_time":"2025-09-25T05:42:48+00:00","article_modified_time":"2025-11-12T14:38:45+00:00","og_image":[{"width":1026,"height":1022,"url":"https:\/\/hueil.top\/wp-content\/uploads\/2025\/10\/78b810f902ae25bada3326b5ec0f6d73.webp","type":"image\/webp"}],"author":"\u5c0f\u5f20","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u5c0f\u5f20","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/hueil.top\/?p=722#article","isPartOf":{"@id":"https:\/\/hueil.top\/?p=722"},"author":{"name":"\u5c0f\u5f20","@id":"https:\/\/hueil.top\/#\/schema\/person\/b3ed2232564570b957865ad1cefe7b88"},"headline":"Python\u57fa\u7840","datePublished":"2025-09-25T05:42:48+00:00","dateModified":"2025-11-12T14:38:45+00:00","mainEntityOfPage":{"@id":"https:\/\/hueil.top\/?p=722"},"wordCount":57,"commentCount":0,"publisher":{"@id":"https:\/\/hueil.top\/#\/schema\/person\/b3ed2232564570b957865ad1cefe7b88"},"image":{"@id":"https:\/\/hueil.top\/?p=722#primaryimage"},"thumbnailUrl":"https:\/\/hueil.top\/wp-content\/uploads\/2025\/10\/78b810f902ae25bada3326b5ec0f6d73.webp","keywords":["Python","\u7b97\u6cd5\u5206\u6790"],"articleSection":["Python"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/hueil.top\/?p=722#respond"]}]},{"@type":"WebPage","@id":"https:\/\/hueil.top\/?p=722","url":"https:\/\/hueil.top\/?p=722","name":"Python\u57fa\u7840 - Hueil\u306e\u5c0f\u7a9d","isPartOf":{"@id":"https:\/\/hueil.top\/#website"},"primaryImageOfPage":{"@id":"https:\/\/hueil.top\/?p=722#primaryimage"},"image":{"@id":"https:\/\/hueil.top\/?p=722#primaryimage"},"thumbnailUrl":"https:\/\/hueil.top\/wp-content\/uploads\/2025\/10\/78b810f902ae25bada3326b5ec0f6d73.webp","datePublished":"2025-09-25T05:42:48+00:00","dateModified":"2025-11-12T14:38:45+00:00","description":"\u8ba1\u7b97\u673a\u5e94\u7528\uff0cPython\uff0cJava\uff0c\u4fe1\u606f\u5b89\u5168\uff0c\u7f51\u7ad9\u7f8e\u5316,\u7269\u8054\u7f51\uff0cC\/C++\u7b97\u6cd5\u5206\u6790,\u7f51\u7ad9\u5b9e\u6218","breadcrumb":{"@id":"https:\/\/hueil.top\/?p=722#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/hueil.top\/?p=722"]}]},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/hueil.top\/?p=722#primaryimage","url":"https:\/\/hueil.top\/wp-content\/uploads\/2025\/10\/78b810f902ae25bada3326b5ec0f6d73.webp","contentUrl":"https:\/\/hueil.top\/wp-content\/uploads\/2025\/10\/78b810f902ae25bada3326b5ec0f6d73.webp","width":1026,"height":1022},{"@type":"BreadcrumbList","@id":"https:\/\/hueil.top\/?p=722#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/hueil.top\/"},{"@type":"ListItem","position":2,"name":"Python\u57fa\u7840"}]},{"@type":"WebSite","@id":"https:\/\/hueil.top\/#website","url":"https:\/\/hueil.top\/","name":"Hueil\u306e\u5c0f\u7a9d","description":"Hueil\u7684\u5c0f\u7834\u7ad9","publisher":{"@id":"https:\/\/hueil.top\/#\/schema\/person\/b3ed2232564570b957865ad1cefe7b88"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/hueil.top\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":["Person","Organization"],"@id":"https:\/\/hueil.top\/#\/schema\/person\/b3ed2232564570b957865ad1cefe7b88","name":"\u5c0f\u5f20","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/hueil.top\/#\/schema\/person\/image\/","url":"https:\/\/hueil.top\/wp-content\/uploads\/2025\/08\/Hueil.jpg","contentUrl":"https:\/\/hueil.top\/wp-content\/uploads\/2025\/08\/Hueil.jpg","width":940,"height":940,"caption":"\u5c0f\u5f20"},"logo":{"@id":"https:\/\/hueil.top\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/hueil.top"],"url":"https:\/\/hueil.top\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/hueil.top\/index.php?rest_route=\/wp\/v2\/posts\/722","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hueil.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hueil.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hueil.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hueil.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=722"}],"version-history":[{"count":28,"href":"https:\/\/hueil.top\/index.php?rest_route=\/wp\/v2\/posts\/722\/revisions"}],"predecessor-version":[{"id":963,"href":"https:\/\/hueil.top\/index.php?rest_route=\/wp\/v2\/posts\/722\/revisions\/963"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hueil.top\/index.php?rest_route=\/wp\/v2\/media\/851"}],"wp:attachment":[{"href":"https:\/\/hueil.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=722"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hueil.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=722"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hueil.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=722"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}