{"id":17,"date":"2024-02-03T14:30:27","date_gmt":"2024-02-03T06:30:27","guid":{"rendered":"https:\/\/www.djlcx.cn\/?p=17"},"modified":"2024-02-03T14:31:44","modified_gmt":"2024-02-03T06:31:44","slug":"python2","status":"publish","type":"post","link":"https:\/\/www.djlcx.cn\/index.php\/2024\/02\/03\/python2\/","title":{"rendered":"Python\u5c0f\u767d\u5165\u95e8\u6307\u5357\uff1a\u4ece\u96f6\u5f00\u59cb\u638c\u63e1Python\u7f16\u7a0b"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u4f60\u662f\u5426\u66fe\u60f3\u8fc7\u7528\u4ee3\u7801\u64cd\u63a7\u7535\u8111\u3001\u5236\u4f5c\u81ea\u52a8\u5316\u4efb\u52a1\uff0c\u6216\u8005\u63a2\u7d22\u6570\u636e\u7684\u5965\u79d8\uff1f\u4eca\u5929\uff0c\u6211\u8981\u5e26\u4f60\u8fdb\u5165Python\u7684\u4e16\u754c\uff0c\u4e3a\u4f60\u63ed\u5f00\u7f16\u7a0b\u7684\u795e\u79d8\u9762\u7eb1\u3002\u4e0d\u8bba\u4f60\u662f\u7f16\u7a0b\u96f6\u57fa\u7840\uff0c\u8fd8\u662f\u60f3\u5b66\u4e60\u4e00\u95e8\u65b0\u6280\u80fd\uff0c\u8fd9\u7bc7\u6587\u7ae0\u90fd\u5c06\u662f\u4f60\u5b66\u4e60Python\u7684\u5f97\u529b\u52a9\u624b\u3002<\/p>\n\n\n\n<p><strong>\u4e00\u3001Python\u662f\u4ec0\u4e48\uff1f\u4e3a\u4ec0\u4e48\u8981\u5b66Python\uff1f<\/strong><\/p>\n\n\n\n<p>Python\u662f\u4e00\u79cd\u9ad8\u7ea7\u3001\u52a8\u6001\u7c7b\u578b\u7684\u7f16\u7a0b\u8bed\u8a00\uff0c\u5b83\u7684\u8bbe\u8ba1\u7406\u5ff5\u662f\u201c\u7b80\u6d01\u81f3\u4e0a\u201d\u3002\u5bf9\u4e8e\u521d\u5b66\u8005\u6765\u8bf4\uff0cPython\u662f\u4e00\u4e2a\u6781\u597d\u7684\u8d77\u70b9\uff0c\u5b83\u6613\u4e8e\u4e0a\u624b\uff0c\u8bed\u6cd5\u7b80\u6d01\u660e\u4e86\u3002\u66f4\u91cd\u8981\u7684\u662f\uff0cPython\u5728\u6570\u636e\u79d1\u5b66\u3001Web\u5f00\u53d1\u3001\u4eba\u5de5\u667a\u80fd\u7b49\u591a\u4e2a\u9886\u57df\u90fd\u6709\u5e7f\u6cdb\u7684\u5e94\u7528\u3002\u638c\u63e1\u4e86Python\uff0c\u4f60\u5c06\u62e5\u6709\u5f00\u542f\u672a\u6765\u79d1\u6280\u5927\u95e8\u7684\u94a5\u5319\u3002<\/p>\n\n\n\n<p><strong>\u4e8c\u3001Python\u5b89\u88c5\u4e0e\u73af\u5883\u914d\u7f6e<\/strong><\/p>\n\n\n\n<p>\u9996\u5148\uff0c\u4f60\u9700\u8981\u4e00\u4e2aPython\u73af\u5883\u3002\u524d\u5f80Python\u5b98\u7f51\u4e0b\u8f7d\u5e76\u5b89\u88c5\u5bf9\u5e94\u4f60\u64cd\u4f5c\u7cfb\u7edf\u7684\u7248\u672c\u3002\u5982\u679c\u4f60\u662fWindows\u7528\u6237\uff0c\u63a8\u8350\u5b89\u88c5Python 3.x\u7248\u672c\uff1bMac\u6216Linux\u7528\u6237\u5219\u9ed8\u8ba4\u5b89\u88c5\u7684\u5e94\u8be5\u662fPython 2.x\uff0c\u4e5f\u53ef\u4ee5\u9009\u62e9\u5347\u7ea7\u5230Python 3.x\u3002<\/p>\n\n\n\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\uff08Windows\u7684CMD\u6216Mac\/Linux\u7684Terminal\uff09\u6765\u9a8c\u8bc1Python\u662f\u5426\u5b89\u88c5\u6210\u529f\u3002\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\uff0c\u5982\u679c\u663e\u793a\u4e86Python\u7684\u7248\u672c\u53f7\uff0c\u90a3\u4e48\u606d\u559c\u4f60\uff0cPython\u5df2\u7ecf\u6210\u529f\u5b89\u88c5\uff01<\/p>\n\n\n\n<p><strong>\u4e09\u3001Python\u7f16\u7a0b\u57fa\u7840<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Hello, World!<\/strong>\uff1a\u8fd9\u662f\u6bcf\u4e00\u4e2a\u7a0b\u5e8f\u5458\u7f16\u5199\u7684\u7b2c\u4e00\u4e2a\u7a0b\u5e8f\u3002\u5728Python\u4e2d\uff0c\u4f60\u53ef\u4ee5\u8fd9\u6837\u5199\uff1a<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>python\u590d\u5236\u4ee3\u7801print(\"Hello, World!\")<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li><strong>\u6570\u636e\u7c7b\u578b\u4e0e\u53d8\u91cf<\/strong>\uff1aPython\u4e2d\u6709\u51e0\u79cd\u57fa\u672c\u7684\u6570\u636e\u7c7b\u578b\uff0c\u5982\u6574\u6570\uff08\u5982123\uff09\u3001\u6d6e\u70b9\u6570\uff08\u5982123.456\uff09\u3001\u5b57\u7b26\u4e32\uff08\u7531\u96f6\u4e2a\u6216\u591a\u4e2a\u5b57\u7b26\u7ec4\u6210\u7684\u6709\u5e8f\u5b57\u7b26\u5e8f\u5217\uff0c\u5982&#8221;Hello&#8221;\uff09\u3002\u4f60\u53ef\u4ee5\u8fd9\u6837\u58f0\u660e\u4e00\u4e2a\u53d8\u91cf\uff1a<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>python\u590d\u5236\u4ee3\u7801a = 10  # \u6574\u6570\u7c7b\u578b\u53d8\u91cf  b = 10.5  # \u6d6e\u70b9\u6570\u7c7b\u578b\u53d8\u91cf  c = \"Hello\"  # \u5b57\u7b26\u4e32\u7c7b\u578b\u53d8\u91cf<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\">\n<li><strong>\u8fd0\u7b97\u7b26\u4e0e\u8868\u8fbe\u5f0f<\/strong>\uff1a\u57fa\u672c\u7684\u7b97\u672f\u8fd0\u7b97\u7b26\u5982\u52a0\uff08+\uff09\u3001\u51cf\uff08-\uff09\u3001\u4e58\uff08*\uff09\u3001\u9664\uff08\/\uff09\u7b49\u5728Python\u4e2d\u90fd\u6709\u5b9a\u4e49\u3002\u4f8b\u5982\uff1a<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>python\u590d\u5236\u4ee3\u7801sum = a + b  # \u52a0\u6cd5  difference = a - b  # \u51cf\u6cd5  product = a * b  # \u4e58\u6cd5  quotient = a \/ b  # \u9664\u6cd5\uff08\u6ce8\u610f\uff1a\u9664\u6cd5\u7ed3\u679c\u4e3a\u6d6e\u70b9\u6570\uff09<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"4\">\n<li><strong>\u6761\u4ef6\u8bed\u53e5<\/strong>\uff1a\u6761\u4ef6\u8bed\u53e5\u7528\u4e8e\u57fa\u4e8e\u4e0d\u540c\u6761\u4ef6\u6267\u884c\u4e0d\u540c\u7684\u64cd\u4f5c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684if\u8bed\u53e5\u793a\u4f8b\uff1a<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>python\u590d\u5236\u4ee3\u7801if a &gt; b:      print(\"a\u5927\u4e8eb\")  elif a &lt; b:      print(\"a\u5c0f\u4e8eb\")  else:      print(\"a\u7b49\u4e8eb\")<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"5\">\n<li><strong>\u5faa\u73af\u8bed\u53e5<\/strong>\uff1a\u5faa\u73af\u8bed\u53e5\u7528\u4e8e\u91cd\u590d\u6267\u884c\u4e00\u6bb5\u4ee3\u7801\u3002\u8fd9\u91cc\u6709\u4e00\u4e2afor\u5faa\u73af\u7684\u4f8b\u5b50\uff1a<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>python\u590d\u5236\u4ee3\u7801for i in range(5):  # \u5faa\u73af5\u6b21\uff0ci\u7684\u503c\u5206\u522b\u4e3a0, 1, 2, 3, 4      print(i)  # \u8f93\u51fa\u5f53\u524di\u7684\u503c<\/code><\/pre>\n\n\n\n<p><strong>\u56db\u3001\u5b9e\u8df5\u51fa\u771f\u77e5<\/strong><br>\u7f16\u7a0b\u662f\u4e00\u95e8\u5b9e\u8df5\u6027\u6781\u5f3a\u7684\u6280\u80fd\u3002\u60f3\u8981\u771f\u6b63\u638c\u63e1Python\uff0c\u4f60\u9700\u8981\u4e0d\u65ad\u5730\u5199\u4ee3\u7801\u3001\u8bd5\u9519\u3001\u518d\u5199\u4ee3\u7801\u3002\u4e00\u5f00\u59cb\u53ef\u80fd\u4f1a\u9047\u5230\u5f88\u591a\u56f0\u96be\uff0c\u4f46\u8bb0\u4f4f\uff0c\u6bcf\u4e00\u6b21\u5931\u8d25\u90fd\u662f\u901a\u5f80\u6210\u529f\u7684\u5fc5\u7ecf\u4e4b\u8def\u3002\u5c1d\u8bd5\u53bb\u89e3\u51b3\u4e00\u4e9b\u5b9e\u9645\u95ee\u9898\uff0c\u6bd4\u5982\u7f16\u5199\u4e00\u4e2a\u7b80\u5355\u7684\u8ba1\u7b97\u5668\u3001\u4e00\u4e2a\u6570\u636e\u6392\u5e8f\u7a0b\u5e8f\uff0c\u6216\u8005\u5236\u4f5c\u4e00\u4e2a\u7f51\u9875\u722c\u866b\u7b49\u3002\u8fd9\u6837\u4e0d\u4ec5\u80fd\u953b\u70bc\u4f60\u7684\u7f16\u7a0b\u6280\u80fd\uff0c\u8fd8\u80fd\u8ba9\u4f60\u611f\u53d7\u5230\u7f16\u7a0b\u7684\u5b9e\u9645\u4ef7\u503c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f60\u662f\u5426\u66fe\u60f3\u8fc7\u7528\u4ee3\u7801\u64cd\u63a7\u7535\u8111\u3001\u5236\u4f5c\u81ea\u52a8\u5316\u4efb\u52a1\uff0c\u6216\u8005\u63a2\u7d22\u6570\u636e\u7684\u5965\u79d8\uff1f\u4eca\u5929\uff0c\u6211\u8981\u5e26\u4f60\u8fdb\u5165Python\u7684\u4e16\u754c\uff0c\u4e3a\u4f60\u63ed\u5f00 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-17","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.djlcx.cn\/index.php\/wp-json\/wp\/v2\/posts\/17","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.djlcx.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.djlcx.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.djlcx.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.djlcx.cn\/index.php\/wp-json\/wp\/v2\/comments?post=17"}],"version-history":[{"count":2,"href":"https:\/\/www.djlcx.cn\/index.php\/wp-json\/wp\/v2\/posts\/17\/revisions"}],"predecessor-version":[{"id":19,"href":"https:\/\/www.djlcx.cn\/index.php\/wp-json\/wp\/v2\/posts\/17\/revisions\/19"}],"wp:attachment":[{"href":"https:\/\/www.djlcx.cn\/index.php\/wp-json\/wp\/v2\/media?parent=17"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.djlcx.cn\/index.php\/wp-json\/wp\/v2\/categories?post=17"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.djlcx.cn\/index.php\/wp-json\/wp\/v2\/tags?post=17"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}