{"id":984803,"date":"2024-12-27T07:31:25","date_gmt":"2024-12-26T23:31:25","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/984803.html"},"modified":"2024-12-27T07:31:27","modified_gmt":"2024-12-26T23:31:27","slug":"%e5%a6%82%e4%bd%95%e5%bc%80%e5%a7%8b%e7%94%a8python%e7%bc%96%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/984803.html","title":{"rendered":"\u5982\u4f55\u5f00\u59cb\u7528python\u7f16\u7a0b"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24212236\/a87b6f27-da50-4409-9148-3f1163023593.webp\" alt=\"\u5982\u4f55\u5f00\u59cb\u7528python\u7f16\u7a0b\" \/><\/p>\n<p><p> <strong>\u8981\u5f00\u59cb\u7528Python\u7f16\u7a0b\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5Python\u89e3\u91ca\u5668\u3001\u9009\u62e9\u4e00\u4e2a\u4ee3\u7801\u7f16\u8f91\u5668\u6216\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u3001\u5b66\u4e60Python\u7684\u57fa\u672c\u8bed\u6cd5\u3001\u901a\u8fc7\u5b9e\u8df5\u9879\u76ee\u52a0\u6df1\u7406\u89e3\u3002<\/strong>\u5176\u4e2d\uff0c\u9009\u62e9\u5408\u9002\u7684IDE\u6216\u7f16\u8f91\u5668\u662f\u4e00\u4e2a\u91cd\u8981\u6b65\u9aa4\uff0c\u5b83\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u4f60\u7684\u7f16\u7a0b\u6548\u7387\u548c\u4f53\u9a8c\u3002Python\u662f\u4e00\u95e8\u6613\u4e8e\u5b66\u4e60\u7684\u7f16\u7a0b\u8bed\u8a00\uff0c\u62e5\u6709\u4e30\u5bcc\u7684\u8d44\u6e90\u548c\u652f\u6301\uff0c\u9002\u5408\u521d\u5b66\u8005\u548c\u4e13\u4e1a\u5f00\u53d1\u8005\u3002<\/p>\n<\/p>\n<p><p>Python\u89e3\u91ca\u5668\u7684\u5b89\u88c5\u662f\u5b66\u4e60Python\u7f16\u7a0b\u7684\u7b2c\u4e00\u6b65\u3002Python\u5b98\u7f51\u63d0\u4f9b\u4e86\u6700\u65b0\u7684\u7a33\u5b9a\u7248\u672c\u4f9b\u4e0b\u8f7d\u3002\u5b89\u88c5\u8fc7\u7a0b\u901a\u5e38\u5f88\u7b80\u5355\uff0c\u4f46\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u786e\u4fdd\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u52fe\u9009\u201c\u6dfb\u52a0Python\u5230PATH\u201d\u9009\u9879\uff0c\u8fd9\u5c06\u6709\u52a9\u4e8e\u5728\u547d\u4ee4\u884c\u4e2d\u8f7b\u677e\u8c03\u7528Python\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165<code>python --version<\/code>\u6765\u68c0\u67e5\u662f\u5426\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u8be6\u7ec6\u63a2\u8ba8\u5982\u4f55\u9009\u62e9\u5408\u9002\u7684\u7f16\u8f91\u5668\u6216IDE\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u9009\u62e9\u5408\u9002\u7684\u7f16\u8f91\u5668\u6216IDE<\/p>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u7f16\u5199Python\u4ee3\u7801\u4e4b\u524d\uff0c\u9009\u62e9\u4e00\u4e2a\u5408\u9002\u7684\u4ee3\u7801\u7f16\u8f91\u5668\u6216\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u662f\u81f3\u5173\u91cd\u8981\u7684\u3002\u8fd9\u4e0d\u4ec5\u5f71\u54cd\u5230\u4f60\u7684\u7f16\u7a0b\u4f53\u9a8c\uff0c\u4e5f\u4f1a\u5f71\u54cd\u5230\u4f60\u7684\u5b66\u4e60\u6548\u7387\u548c\u4ee3\u7801\u8d28\u91cf\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684Python\u7f16\u8f91\u5668\u548cIDE\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>VS Code\uff08Visual Studio Code\uff09<\/strong><\/p>\n<\/p>\n<p><p>Visual Studio Code\u662f\u7531\u5fae\u8f6f\u5f00\u53d1\u7684\u4e00\u6b3e\u514d\u8d39\u3001\u5f00\u6e90\u7684\u4ee3\u7801\u7f16\u8f91\u5668\u3002\u5b83\u652f\u6301\u591a\u79cd\u7f16\u7a0b\u8bed\u8a00\uff0c\u5e76\u4e14\u5177\u6709\u5f3a\u5927\u7684\u63d2\u4ef6\u751f\u6001\u7cfb\u7edf\uff0c\u53ef\u4ee5\u901a\u8fc7\u5b89\u88c5\u6269\u5c55\u6765\u652f\u6301Python\u7f16\u7a0b\u3002VS Code\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u8c03\u8bd5\u529f\u80fd\u3001\u5185\u7f6e\u7684Git\u63a7\u5236\u3001\u667a\u80fd\u4ee3\u7801\u8865\u5168\u3001\u8bed\u6cd5\u9ad8\u4eae\u7b49\u7279\u6027\uff0c\u975e\u5e38\u9002\u5408Python\u5f00\u53d1\u3002<\/p>\n<\/p>\n<p><p>\u521d\u5b66\u8005\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5728VS Code\u4e2d\u8bbe\u7f6ePython\u5f00\u53d1\u73af\u5883\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u4e0b\u8f7d\u5e76\u5b89\u88c5VS Code\u3002<\/li>\n<li>\u6253\u5f00VS Code\u540e\uff0c\u8fdb\u5165\u6269\u5c55\u5e02\u573a\uff0c\u641c\u7d22\u5e76\u5b89\u88c5\u201cPython\u201d\u6269\u5c55\u3002<\/li>\n<li>\u914d\u7f6ePython\u89e3\u91ca\u5668\u8def\u5f84\uff0c\u4ee5\u4fbf\u4e8eVS Code\u8bc6\u522bPython\u73af\u5883\u3002<\/li>\n<li>\u901a\u8fc7\u7ec8\u7aef\u8fd0\u884cPython\u6587\u4ef6\uff0c\u5f00\u59cb\u7f16\u5199\u548c\u8c03\u8bd5Python\u4ee3\u7801\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>PyCharm<\/strong><\/p>\n<\/p>\n<p><p>PyCharm\u662f\u7531JetBr<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>ns\u5f00\u53d1\u7684\u4e00\u6b3e\u4e13\u6ce8\u4e8ePython\u5f00\u53d1\u7684IDE\u3002\u5b83\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u4ee3\u7801\u5206\u6790\u5de5\u5177\u3001\u8c03\u8bd5\u529f\u80fd\u3001\u6d4b\u8bd5\u5de5\u5177\u96c6\u6210\u7b49\uff0c\u662f\u4e13\u4e1aPython\u5f00\u53d1\u8005\u7684\u7406\u60f3\u9009\u62e9\u3002PyCharm\u5206\u4e3a\u793e\u533a\u7248\uff08\u514d\u8d39\uff09\u548c\u4e13\u4e1a\u7248\uff08\u6536\u8d39\uff09\uff0c\u5bf9\u4e8e\u521d\u5b66\u8005\u800c\u8a00\uff0c\u793e\u533a\u7248\u5df2\u7ecf\u8db3\u591f\u4f7f\u7528\u3002<\/p>\n<\/p>\n<p><p>\u4f7f\u7528PyCharm\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u4ecePyCharm\u5b98\u7f51\u4e0b\u8f7d\u5b89\u88c5\u8f6f\u4ef6\u3002<\/li>\n<li>\u542f\u52a8PyCharm\u5e76\u65b0\u5efa\u4e00\u4e2aPython\u9879\u76ee\u3002<\/li>\n<li>\u914d\u7f6e\u9879\u76ee\u7684Python\u73af\u5883\uff0c\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528\u865a\u62df\u73af\u5883\u6216\u73b0\u6709\u7684Python\u89e3\u91ca\u5668\u3002<\/li>\n<li>\u5f00\u59cb\u7f16\u5199Python\u811a\u672c\uff0c\u4f7f\u7528PyCharm\u7684\u8c03\u8bd5\u548c\u6d4b\u8bd5\u529f\u80fd\uff0c\u63d0\u9ad8\u4ee3\u7801\u8d28\u91cf\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>Jupyter Notebook<\/strong><\/p>\n<\/p>\n<p><p>Jupyter Notebook\u662f\u4e00\u6b3e\u7528\u4e8e\u4ea4\u4e92\u5f0f\u7f16\u7a0b\u548c\u6570\u636e\u5206\u6790\u7684\u5de5\u5177\uff0c\u7279\u522b\u9002\u5408\u6570\u636e\u79d1\u5b66\u3001<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u7b49\u9886\u57df\u3002\u5b83\u5141\u8bb8\u7528\u6237\u5728\u4e00\u4e2a\u6587\u6863\u4e2d\u7f16\u5199\u4ee3\u7801\u3001\u8fd0\u884c\u4ee3\u7801\u3001\u53ef\u89c6\u5316\u6570\u636e\u548c\u64b0\u5199\u6587\u6863\uff0c\u63d0\u4f9b\u4e86\u4e00\u79cd\u76f4\u89c2\u7684\u7f16\u7a0b\u4f53\u9a8c\u3002<\/p>\n<\/p>\n<p><p>\u8981\u4f7f\u7528Jupyter Notebook\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5b89\u88c5\u548c\u8fd0\u884c\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u5b89\u88c5Anaconda\uff0c\u5b83\u662f\u4e00\u4e2a\u5305\u542bPython\u53ca\u5176\u6570\u636e\u79d1\u5b66\u5e93\u7684\u5f00\u6e90\u53d1\u884c\u7248\uff0c\u5185\u7f6eJupyter Notebook\u3002<\/li>\n<li>\u6253\u5f00Anaconda Navigator\uff0c\u542f\u52a8Jupyter Notebook\u3002<\/li>\n<li>\u5728\u6d4f\u89c8\u5668\u4e2d\u6253\u5f00Jupyter\u754c\u9762\uff0c\u521b\u5efa\u65b0\u7684Notebook\u6587\u4ef6\uff0c\u5f00\u59cb\u7f16\u5199\u548c\u8fd0\u884cPython\u4ee3\u7801\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u5b66\u4e60Python\u7684\u57fa\u672c\u8bed\u6cd5<\/p>\n<\/p>\n<p><p>\u5b66\u4e60Python\u7684\u57fa\u672c\u8bed\u6cd5\u662f\u638c\u63e1Python\u7f16\u7a0b\u7684\u5173\u952e\u6b65\u9aa4\u3002Python\u4ee5\u5176\u7b80\u6d01\u7684\u8bed\u6cd5\u548c\u6613\u8bfb\u6027\u8457\u79f0\uff0c\u4f7f\u5176\u6210\u4e3a\u521d\u5b66\u8005\u7684\u7406\u60f3\u9009\u62e9\u3002\u5728\u5b66\u4e60\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u4ee5\u4ece\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762\u5165\u624b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u53d8\u91cf\u548c\u6570\u636e\u7c7b\u578b<\/strong><\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u53d8\u91cf\u662f\u7528\u4e8e\u5b58\u50a8\u6570\u636e\u7684\u5bb9\u5668\u3002Python\u652f\u6301\u591a\u79cd\u6570\u636e\u7c7b\u578b\uff0c\u5305\u62ec\u6574\u6570\u3001\u6d6e\u70b9\u6570\u3001\u5b57\u7b26\u4e32\u3001\u5e03\u5c14\u503c\u7b49\u3002\u7406\u89e3\u4e0d\u540c\u7684\u6570\u636e\u7c7b\u578b\u53ca\u5176\u64cd\u4f5c\u662f\u7f16\u7a0b\u7684\u57fa\u7840\u3002<\/p>\n<\/p>\n<p><p>\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">age = 25  # \u6574\u6570<\/p>\n<p>height = 175.5  # \u6d6e\u70b9\u6570<\/p>\n<p>name = &quot;Alice&quot;  # \u5b57\u7b26\u4e32<\/p>\n<p>is_student = True  # \u5e03\u5c14\u503c<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>Python\u662f\u52a8\u6001\u7c7b\u578b\u8bed\u8a00\uff0c\u56e0\u6b64\u4e0d\u9700\u8981\u663e\u5f0f\u58f0\u660e\u53d8\u91cf\u7c7b\u578b\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u63a7\u5236\u7ed3\u6784<\/strong><\/p>\n<\/p>\n<p><p>\u63a7\u5236\u7ed3\u6784\u7528\u4e8e\u63a7\u5236\u7a0b\u5e8f\u7684\u6267\u884c\u6d41\u7a0b\u3002Python\u63d0\u4f9b\u4e86\u591a\u79cd\u63a7\u5236\u7ed3\u6784\uff0c\u5305\u62ec\u6761\u4ef6\u8bed\u53e5\u3001\u5faa\u73af\u8bed\u53e5\u7b49\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p>\u6761\u4ef6\u8bed\u53e5\uff1a<code>if<\/code>\u3001<code>elif<\/code>\u3001<code>else<\/code>\u7528\u4e8e\u6839\u636e\u6761\u4ef6\u6267\u884c\u4e0d\u540c\u7684\u4ee3\u7801\u5757\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">if age &gt;= 18:<\/p>\n<p>    print(&quot;You are an adult.&quot;)<\/p>\n<p>else:<\/p>\n<p>    print(&quot;You are a minor.&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u5faa\u73af\u8bed\u53e5\uff1a<code>for<\/code>\u5faa\u73af\u7528\u4e8e\u8fed\u4ee3\u5e8f\u5217\uff0c<code>while<\/code>\u5faa\u73af\u7528\u4e8e\u5728\u6761\u4ef6\u4e3a\u771f\u65f6\u53cd\u590d\u6267\u884c\u4ee3\u7801\u5757\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">for i in range(5):<\/p>\n<p>    print(i)<\/p>\n<p>count = 0<\/p>\n<p>while count &lt; 5:<\/p>\n<p>    print(count)<\/p>\n<p>    count += 1<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u51fd\u6570\u548c\u6a21\u5757<\/strong><\/p>\n<\/p>\n<p><p>\u51fd\u6570\u662f\u6267\u884c\u7279\u5b9a\u4efb\u52a1\u7684\u4ee3\u7801\u5757\u3002Python\u901a\u8fc7<code>def<\/code>\u5173\u952e\u5b57\u5b9a\u4e49\u51fd\u6570\uff0c\u652f\u6301\u53c2\u6570\u4f20\u9012\u548c\u8fd4\u56de\u503c\u3002\u6a21\u5757\u662f\u5305\u542b\u51fd\u6570\u3001\u7c7b\u548c\u53d8\u91cf\u7684\u6587\u4ef6\uff0c\u53ef\u4ee5\u901a\u8fc7<code>import<\/code>\u8bed\u53e5\u5bfc\u5165\u4f7f\u7528\u3002<\/p>\n<\/p>\n<p><p>\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def greet(name):<\/p>\n<p>    return f&quot;Hello, {name}!&quot;<\/p>\n<p>print(greet(&quot;Alice&quot;))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f7f\u7528\u6807\u51c6\u5e93\u6a21\u5757\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<p>print(math.sqrt(16))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u901a\u8fc7\u5b9e\u8df5\u9879\u76ee\u52a0\u6df1\u7406\u89e3<\/p>\n<\/p>\n<p><p>\u5b66\u4e60\u7f16\u7a0b\u8bed\u8a00\u6700\u6709\u6548\u7684\u65b9\u6cd5\u662f\u901a\u8fc7\u5b9e\u8df5\u9879\u76ee\u6765\u5e94\u7528\u6240\u5b66\u77e5\u8bc6\u3002\u9009\u62e9\u5408\u9002\u7684\u9879\u76ee\u53ef\u4ee5\u5e2e\u52a9\u5de9\u56fa\u57fa\u7840\u77e5\u8bc6\uff0c\u63d0\u9ad8\u7f16\u7a0b\u6280\u80fd\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u9002\u5408\u521d\u5b66\u8005\u7684Python\u9879\u76ee\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u547d\u4ee4\u884c\u8ba1\u7b97\u5668<\/strong><\/p>\n<\/p>\n<p><p>\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u547d\u4ee4\u884c\u8ba1\u7b97\u5668\uff0c\u652f\u6301\u52a0\u3001\u51cf\u3001\u4e58\u3001\u9664\u7b49\u57fa\u672c\u8fd0\u7b97\u3002\u8fd9\u4e2a\u9879\u76ee\u53ef\u4ee5\u5e2e\u52a9\u7406\u89e3\u7528\u6237\u8f93\u5165\u3001\u51fd\u6570\u8c03\u7528\u548c\u6761\u4ef6\u5224\u65ad\u3002<\/p>\n<\/p>\n<p><p>\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def add(x, y):<\/p>\n<p>    return x + y<\/p>\n<p>def subtract(x, y):<\/p>\n<p>    return x - y<\/p>\n<p>def multiply(x, y):<\/p>\n<p>    return x * y<\/p>\n<p>def divide(x, y):<\/p>\n<p>    if y != 0:<\/p>\n<p>        return x \/ y<\/p>\n<p>    else:<\/p>\n<p>        return &quot;Cannot divide by zero&quot;<\/p>\n<p>print(&quot;Select operation:&quot;)<\/p>\n<p>print(&quot;1.Add&quot;)<\/p>\n<p>print(&quot;2.Subtract&quot;)<\/p>\n<p>print(&quot;3.Multiply&quot;)<\/p>\n<p>print(&quot;4.Divide&quot;)<\/p>\n<p>choice = input(&quot;Enter choice(1\/2\/3\/4): &quot;)<\/p>\n<p>num1 = float(input(&quot;Enter first number: &quot;))<\/p>\n<p>num2 = float(input(&quot;Enter second number: &quot;))<\/p>\n<p>if choice == &#39;1&#39;:<\/p>\n<p>    print(add(num1, num2))<\/p>\n<p>elif choice == &#39;2&#39;:<\/p>\n<p>    print(subtract(num1, num2))<\/p>\n<p>elif choice == &#39;3&#39;:<\/p>\n<p>    print(multiply(num1, num2))<\/p>\n<p>elif choice == &#39;4&#39;:<\/p>\n<p>    print(divide(num1, num2))<\/p>\n<p>else:<\/p>\n<p>    print(&quot;Invalid input&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8bb0\u4e8b\u672c\u5e94\u7528<\/strong><\/p>\n<\/p>\n<p><p>\u5f00\u53d1\u4e00\u4e2a\u7b80\u5355\u7684\u8bb0\u4e8b\u672c\u5e94\u7528\uff0c\u5141\u8bb8\u7528\u6237\u6dfb\u52a0\u3001\u67e5\u770b\u548c\u5220\u9664\u7b14\u8bb0\u3002\u8fd9\u4e2a\u9879\u76ee\u6d89\u53ca\u6587\u4ef6\u8bfb\u5199\u64cd\u4f5c\u3001\u5217\u8868\u7ba1\u7406\u548c\u7528\u6237\u754c\u9762\u8bbe\u8ba1\u3002<\/p>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u4f7f\u7528\u6587\u672c\u6587\u4ef6\u4fdd\u5b58\u7b14\u8bb0\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def write_note(note):<\/p>\n<p>    with open(&quot;notes.txt&quot;, &quot;a&quot;) as file:<\/p>\n<p>        file.write(note + &quot;\\n&quot;)<\/p>\n<p>def read_notes():<\/p>\n<p>    with open(&quot;notes.txt&quot;, &quot;r&quot;) as file:<\/p>\n<p>        notes = file.readlines()<\/p>\n<p>    for note in notes:<\/p>\n<p>        print(note.strip())<\/p>\n<p>def delete_note(note_to_delete):<\/p>\n<p>    with open(&quot;notes.txt&quot;, &quot;r&quot;) as file:<\/p>\n<p>        notes = file.readlines()<\/p>\n<p>    with open(&quot;notes.txt&quot;, &quot;w&quot;) as file:<\/p>\n<p>        for note in notes:<\/p>\n<p>            if note.strip() != note_to_delete:<\/p>\n<p>                file.write(note)<\/p>\n<p>write_note(&quot;Learn Python&quot;)<\/p>\n<p>write_note(&quot;Build a project&quot;)<\/p>\n<p>read_notes()<\/p>\n<p>delete_note(&quot;Learn Python&quot;)<\/p>\n<p>read_notes()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5929\u6c14\u67e5\u8be2\u5e94\u7528<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528API\u63a5\u53e3\u5f00\u53d1\u4e00\u4e2a\u5929\u6c14\u67e5\u8be2\u5e94\u7528\u3002\u901a\u8fc7\u8c03\u7528\u7b2c\u4e09\u65b9API\u83b7\u53d6\u5b9e\u65f6\u5929\u6c14\u4fe1\u606f\uff0c\u5c55\u793a\u7ed9\u7528\u6237\u3002\u8fd9\u4e2a\u9879\u76ee\u53ef\u4ee5\u5e2e\u52a9\u7406\u89e3\u7f51\u7edc\u8bf7\u6c42\u3001JSON\u6570\u636e\u89e3\u6790\u548cAPI\u7684\u4f7f\u7528\u3002<\/p>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u4f7f\u7528<code>requests<\/code>\u5e93\u8fdb\u884cAPI\u8bf7\u6c42\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<p>def get_weather(city):<\/p>\n<p>    api_key = &quot;your_api_key_here&quot;<\/p>\n<p>    base_url = &quot;http:\/\/api.openweathermap.org\/data\/2.5\/weather?&quot;<\/p>\n<p>    complete_url = base_url + &quot;q=&quot; + city + &quot;&amp;appid=&quot; + api_key<\/p>\n<p>    response = requests.get(complete_url)<\/p>\n<p>    data = response.json()<\/p>\n<p>    if data[&quot;cod&quot;] != &quot;404&quot;:<\/p>\n<p>        main = data[&quot;main&quot;]<\/p>\n<p>        weather = data[&quot;weather&quot;]<\/p>\n<p>        temperature = main[&quot;temp&quot;]<\/p>\n<p>        weather_description = weather[0][&quot;description&quot;]<\/p>\n<p>        print(f&quot;Temperature: {temperature}&quot;)<\/p>\n<p>        print(f&quot;Weather description: {weather_description}&quot;)<\/p>\n<p>    else:<\/p>\n<p>        print(&quot;City Not Found&quot;)<\/p>\n<p>get_weather(&quot;London&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u52a0\u5165Python\u793e\u533a\u548c\u83b7\u53d6\u8d44\u6e90<\/p>\n<\/p>\n<p><p>\u5728\u5b66\u4e60Python\u7f16\u7a0b\u7684\u8fc7\u7a0b\u4e2d\uff0c\u52a0\u5165Python\u793e\u533a\u548c\u5229\u7528\u4e30\u5bcc\u7684\u5728\u7ebf\u8d44\u6e90\u53ef\u4ee5\u5e2e\u52a9\u89e3\u51b3\u7591\u95ee\u3001\u83b7\u53d6\u652f\u6301\u548c\u52a0\u901f\u5b66\u4e60\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u63a8\u8350\u7684\u8d44\u6e90\u548c\u793e\u533a\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5728\u7ebf\u6559\u7a0b\u548c\u6587\u6863<\/strong><\/p>\n<\/p>\n<p><p>Python\u5b98\u7f51\u63d0\u4f9b\u4e86\u8be6\u7ec6\u7684\u5b98\u65b9\u6587\u6863\u548c\u6559\u7a0b\uff0c\u662f\u5b66\u4e60Python\u7684\u6700\u4f73\u8d77\u70b9\u3002\u6b64\u5916\uff0c\u8bb8\u591a\u5728\u7ebf\u5e73\u53f0\u63d0\u4f9b\u514d\u8d39\u7684Python\u8bfe\u7a0b\u548c\u6559\u7a0b\uff0c\u5982Codecademy\u3001Coursera\u3001edX\u7b49\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7f16\u7a0b\u8bba\u575b\u548c\u793e\u533a<\/strong><\/p>\n<\/p>\n<p><p>\u52a0\u5165\u7f16\u7a0b\u8bba\u575b\u548c\u793e\u533a\u53ef\u4ee5\u4e0e\u5176\u4ed6\u5f00\u53d1\u8005\u4ea4\u6d41\u7ecf\u9a8c\u3001\u5206\u4eab\u8d44\u6e90\u3002Stack Overflow\u662f\u4e00\u4e2a\u53d7\u6b22\u8fce\u7684\u7f16\u7a0b\u95ee\u7b54\u793e\u533a\uff0cPython\u5b50\u7248\u5757\u6709\u5927\u91cf\u7684\u95ee\u9898\u548c\u7b54\u6848\u3002Reddit\u7684Python\u7248\u5757\u4e5f\u662f\u4e00\u4e2a\u8ba8\u8bbaPython\u76f8\u5173\u8bdd\u9898\u7684\u6d3b\u8dc3\u793e\u533a\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5f00\u6e90\u9879\u76ee<\/strong><\/p>\n<\/p>\n<p><p>\u53c2\u4e0e\u5f00\u6e90\u9879\u76ee\u662f\u63d0\u9ad8\u7f16\u7a0b\u6280\u80fd\u7684\u6709\u6548\u65b9\u6cd5\u3002\u53ef\u4ee5\u5728GitHub\u4e0a\u5bfb\u627e\u611f\u5174\u8da3\u7684Python\u5f00\u6e90\u9879\u76ee\uff0c\u901a\u8fc7\u9605\u8bfb\u4ee3\u7801\u3001\u63d0\u4ea4Pull Request\u3001\u89e3\u51b3\u95ee\u9898\u7b49\u65b9\u5f0f\u8fdb\u884c\u5b66\u4e60\u548c\u8d21\u732e\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u672c\u5730\u548c\u5728\u7ebf\u6d3b\u52a8<\/strong><\/p>\n<\/p>\n<p><p>\u53c2\u52a0\u672c\u5730\u7684Python\u7528\u6237\u7ec4\uff08PUG\uff09\u6d3b\u52a8\u6216\u5728\u7ebf\u7684Python\u4f1a\u8bae\u3001\u7f51\u7edc\u7814\u8ba8\u4f1a\uff0c\u53ef\u4ee5\u4e0e\u5176\u4ed6Python\u7231\u597d\u8005\u4ea4\u6d41\u3001\u5b66\u4e60\u65b0\u6280\u672f\u3002PyCon\u662f\u5168\u7403\u6700\u5927\u7684Python\u793e\u533a\u4f1a\u8bae\uff0c\u6bcf\u5e74\u5728\u591a\u4e2a\u56fd\u5bb6\u548c\u5730\u533a\u4e3e\u529e\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u6b65\u9aa4\u548c\u8d44\u6e90\uff0c\u65b0\u624b\u53ef\u4ee5\u9010\u6b65\u638c\u63e1Python\u7f16\u7a0b\uff0c\u5e76\u5728\u5b9e\u8df5\u4e2d\u4e0d\u65ad\u63d0\u9ad8\u81ea\u5df1\u7684\u7f16\u7a0b\u80fd\u529b\u3002Python\u7684\u5e7f\u6cdb\u5e94\u7528\u9886\u57df\u4e3a\u5b66\u4e60\u8005\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u673a\u4f1a\uff0c\u65e0\u8bba\u662f\u6570\u636e\u79d1\u5b66\u3001Web\u5f00\u53d1\u3001\u81ea\u52a8\u5316\uff0c\u8fd8\u662f<a href=\"https:\/\/docs.pingcode.com\/tag\/AI\" target=\"_blank\">\u4eba\u5de5\u667a\u80fd<\/a>\u3001\u6e38\u620f\u5f00\u53d1\uff0c\u90fd\u53ef\u4ee5\u5229\u7528Python\u7684\u5f3a\u5927\u529f\u80fd\u5b9e\u73b0\u76ee\u6807\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u9009\u62e9\u9002\u5408\u521d\u5b66\u8005\u7684Python\u5b66\u4e60\u8d44\u6e90\uff1f<\/strong><br \/>\u521d\u5b66\u8005\u53ef\u4ee5\u9009\u62e9\u591a\u79cd\u5b66\u4e60\u8d44\u6e90\u6765\u5f00\u59cbPython\u7f16\u7a0b\uff0c\u6bd4\u5982\u5728\u7ebf\u8bfe\u7a0b\u3001\u4e66\u7c4d\u548c\u89c6\u9891\u6559\u7a0b\u3002\u63a8\u8350\u7684\u5728\u7ebf\u5e73\u53f0\u5305\u62ecCoursera\u3001edX\u548cCodecademy\u7b49\uff0c\u8fd9\u4e9b\u5e73\u53f0\u63d0\u4f9b\u7ed3\u6784\u5316\u7684\u8bfe\u7a0b\uff0c\u9002\u5408\u4e0d\u540c\u5b66\u4e60\u98ce\u683c\u7684\u5b66\u751f\u3002\u6b64\u5916\uff0c\u4e00\u4e9b\u7ecf\u5178\u4e66\u7c4d\u5982\u300aPython\u7f16\u7a0b\uff1a\u4ece\u5165\u95e8\u5230\u5b9e\u8df5\u300b\u4e5f\u975e\u5e38\u9002\u5408\u521d\u5b66\u8005\u3002<\/p>\n<p><strong>\u6211\u9700\u8981\u54ea\u4e9b\u5de5\u5177\u6765\u5f00\u59cbPython\u7f16\u7a0b\uff1f<\/strong><br \/>\u8981\u5f00\u59cbPython\u7f16\u7a0b\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5Python\u89e3\u91ca\u5668\u3002\u53ef\u4ee5\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684Python\u3002\u5b89\u88c5\u540e\uff0c\u521d\u5b66\u8005\u8fd8\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\uff0c\u5982PyCharm\u3001Visual Studio Code\u6216Jupyter Notebook\uff0c\u4ee5\u4fbf\u66f4\u65b9\u4fbf\u5730\u7f16\u5199\u548c\u8c03\u8bd5\u4ee3\u7801\u3002<\/p>\n<p><strong>\u5b66\u4e60Python\u7f16\u7a0b\u7684\u6700\u4f73\u5b9e\u8df5\u662f\u4ec0\u4e48\uff1f<\/strong><br \/>\u4e3a\u4e86\u6709\u6548\u5b66\u4e60Python\uff0c\u5efa\u8bae\u5b9a\u671f\u8fdb\u884c\u5b9e\u8df5\uff0c\u7f16\u5199\u4ee3\u7801\u5e76\u89e3\u51b3\u5b9e\u9645\u95ee\u9898\u3002\u53c2\u4e0e\u7f16\u7a0b\u6311\u6218\u548c\u5f00\u6e90\u9879\u76ee\u4e5f\u662f\u63d0\u9ad8\u6280\u80fd\u7684\u597d\u65b9\u6cd5\u3002\u6b64\u5916\uff0c\u52a0\u5165\u7f16\u7a0b\u793e\u533a\u548c\u8bba\u575b\uff0c\u5982Stack Overflow\u6216Reddit\uff0c\u53ef\u4ee5\u5411\u5176\u4ed6\u5f00\u53d1\u8005\u8bf7\u6559\u95ee\u9898\u5e76\u83b7\u53d6\u53cd\u9988\uff0c\u5e2e\u52a9\u81ea\u5df1\u5feb\u901f\u6210\u957f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u5f00\u59cb\u7528Python\u7f16\u7a0b\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5Python\u89e3\u91ca\u5668\u3001\u9009\u62e9\u4e00\u4e2a\u4ee3\u7801\u7f16\u8f91\u5668\u6216\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u3001\u5b66\u4e60Py [&hellip;]","protected":false},"author":3,"featured_media":984811,"comment_status":"closed","ping_status":"","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\/984803"}],"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\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=984803"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/984803\/revisions"}],"predecessor-version":[{"id":984815,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/984803\/revisions\/984815"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/984811"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=984803"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=984803"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=984803"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}