{"id":1157780,"date":"2025-01-13T18:32:45","date_gmt":"2025-01-13T10:32:45","guid":{"rendered":""},"modified":"2025-01-13T18:32:47","modified_gmt":"2025-01-13T10:32:47","slug":"python%e5%a6%82%e4%bd%95%e8%87%aa%e5%b7%b1%e5%86%99%e7%a8%8b%e5%ba%8f","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1157780.html","title":{"rendered":"python\u5982\u4f55\u81ea\u5df1\u5199\u7a0b\u5e8f"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25195912\/e29575a4-d88f-4f27-a9b6-b5682610e200.webp\" alt=\"python\u5982\u4f55\u81ea\u5df1\u5199\u7a0b\u5e8f\" \/><\/p>\n<p><p> <strong>Python\u5982\u4f55\u81ea\u5df1\u5199\u7a0b\u5e8f\uff1f<\/strong><\/p>\n<\/p>\n<p><p>\u8981\u81ea\u5df1\u7f16\u5199Python\u7a0b\u5e8f\uff0c\u9996\u5148\u9700\u8981<strong>\u9009\u62e9\u5408\u9002\u7684\u5f00\u53d1\u73af\u5883\u3001\u5b66\u4e60Python\u57fa\u7840\u8bed\u6cd5\u3001\u7406\u89e3\u7f16\u7a0b\u903b\u8f91\u3001\u638c\u63e1\u5e38\u7528\u7684Python\u5e93\u548c\u6a21\u5757\u3001\u8fdb\u884c\u5b9e\u9645\u9879\u76ee\u7ec3\u4e60\u3001\u4e0d\u65ad\u8c03\u8bd5\u548c\u4f18\u5316\u7a0b\u5e8f<\/strong>\u3002\u5176\u4e2d\uff0c<strong>\u9009\u62e9\u5408\u9002\u7684\u5f00\u53d1\u73af\u5883<\/strong>\u662f\u6700\u4e3a\u57fa\u7840\u7684\u4e00\u6b65\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u4f60\u987a\u5229\u5730\u5f00\u59cb\u7f16\u7a0b\u4e4b\u65c5\u3002\u5f00\u53d1\u73af\u5883\u5305\u62ecPython\u89e3\u91ca\u5668\u548c\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u3002Python\u89e3\u91ca\u5668\u53ef\u4ee5\u76f4\u63a5\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\uff0c\u800cIDE\u5982PyCharm\u3001VS Code\u3001Jupyter Notebook\u7b49\u5219\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u529f\u80fd\u6765\u8f85\u52a9\u7f16\u5199\u548c\u8c03\u8bd5\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><p>\u9009\u62e9\u5408\u9002\u7684\u5f00\u53d1\u73af\u5883\u80fd\u591f\u6781\u5927\u63d0\u5347\u7f16\u7a0b\u6548\u7387\u3002\u4f8b\u5982\uff0cPyCharm\u662f\u4e00\u4e2a\u529f\u80fd\u975e\u5e38\u5f3a\u5927\u7684IDE\uff0c\u5b83\u63d0\u4f9b\u4e86\u667a\u80fd\u4ee3\u7801\u8865\u5168\u3001\u4ee3\u7801\u68c0\u67e5\u3001\u8c03\u8bd5\u3001\u6d4b\u8bd5\u7b49\u591a\u79cd\u529f\u80fd\uff0c\u6781\u5927\u5730\u7b80\u5316\u4e86\u5f00\u53d1\u8fc7\u7a0b\u3002\u901a\u8fc7\u4f7f\u7528PyCharm\uff0c\u4f60\u53ef\u4ee5\u66f4\u5feb\u5730\u627e\u5230\u4ee3\u7801\u4e2d\u7684\u9519\u8bef\u5e76\u8fdb\u884c\u4fee\u6b63\uff0c\u63d0\u9ad8\u7f16\u7a0b\u6548\u7387\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u9009\u62e9\u5408\u9002\u7684\u5f00\u53d1\u73af\u5883<\/h3>\n<\/p>\n<p><h4>1.1 Python\u89e3\u91ca\u5668<\/h4>\n<\/p>\n<p><p>Python\u89e3\u91ca\u5668\u662f\u8fd0\u884cPython\u4ee3\u7801\u7684\u6838\u5fc3\u5de5\u5177\u3002\u53ef\u4ee5\u76f4\u63a5\u4ecePython\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/www.python.org\/%EF%BC%89%E4%B8%8B%E8%BD%BD%E5%B9%B6%E5%AE%89%E8%A3%85%E7%9B%B8%E5%BA%94%E7%9A%84%E7%89%88%E6%9C%AC%E3%80%82%E5%AE%89%E8%A3%85%E5%AE%8C%E6%88%90%E5%90%8E%EF%BC%8C%E5%8F%AF%E4%BB%A5%E9%80%9A%E8%BF%87%E5%91%BD%E4%BB%A4%E8%A1%8C%E6%88%96%E7%BB%88%E7%AB%AF%E8%BE%93%E5%85%A5%60python%60%E5%91%BD%E4%BB%A4%E6%9D%A5%E5%90%AF%E5%8A%A8%E8%A7%A3%E9%87%8A%E5%99%A8%EF%BC%8C%E8%BF%9B%E8%A1%8C%E4%BA%A4%E4%BA%92%E5%BC%8F%E7%BC%96%E7%A8%8B%E3%80%82\">https:\/\/www.python.org\/\uff09\u4e0b\u8f7d\u5e76\u5b89\u88c5\u76f8\u5e94\u7684\u7248\u672c\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u8f93\u5165`python`\u547d\u4ee4\u6765\u542f\u52a8\u89e3\u91ca\u5668\uff0c\u8fdb\u884c\u4ea4\u4e92\u5f0f\u7f16\u7a0b\u3002<\/a><\/p>\n<\/p>\n<p><h4>1.2 \u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09<\/h4>\n<\/p>\n<p><p>\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u529f\u80fd\u6765\u8f85\u52a9\u7f16\u5199\u548c\u8c03\u8bd5\u4ee3\u7801\u3002\u5e38\u7528\u7684Python IDE\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>PyCharm<\/strong>\uff1a\u529f\u80fd\u5f3a\u5927\uff0c\u9002\u5408\u5927\u578b\u9879\u76ee\u5f00\u53d1\u3002<\/li>\n<li><strong>VS Code<\/strong>\uff1a\u8f7b\u91cf\u7ea7\uff0c\u63d2\u4ef6\u4e30\u5bcc\uff0c\u9002\u5408\u5404\u79cd\u89c4\u6a21\u7684\u9879\u76ee\u3002<\/li>\n<li><strong>Jupyter Notebook<\/strong>\uff1a\u4ea4\u4e92\u5f0f\u7f16\u7a0b\u5de5\u5177\uff0c\u9002\u5408\u6570\u636e\u5206\u6790\u548c\u79d1\u5b66\u8ba1\u7b97\u3002<\/li>\n<\/ul>\n<p><p><strong>\u4f7f\u7528IDE\u53ef\u4ee5\u63d0\u9ad8\u7f16\u7a0b\u6548\u7387\u548c\u4ee3\u7801\u8d28\u91cf\u3002<\/strong><\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u5b66\u4e60Python\u57fa\u7840\u8bed\u6cd5<\/h3>\n<\/p>\n<p><h4>2.1 \u53d8\u91cf\u548c\u6570\u636e\u7c7b\u578b<\/h4>\n<\/p>\n<p><p>Python\u652f\u6301\u591a\u79cd\u6570\u636e\u7c7b\u578b\uff0c\u5305\u62ec\u6574\u6570\u3001\u6d6e\u70b9\u6570\u3001\u5b57\u7b26\u4e32\u3001\u5217\u8868\u3001\u5143\u7ec4\u3001\u5b57\u5178\u7b49\u3002\u53d8\u91cf\u662f\u5b58\u50a8\u6570\u636e\u7684\u5bb9\u5668\uff0c\u53ef\u4ee5\u901a\u8fc7<code>=<\/code>\u8fdb\u884c\u8d4b\u503c\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">x = 10<\/p>\n<p>name = &quot;Alice&quot;<\/p>\n<p>grades = [90, 85, 92]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2.2 \u63a7\u5236\u7ed3\u6784<\/h4>\n<\/p>\n<p><p>Python\u63d0\u4f9b\u4e86\u591a\u79cd\u63a7\u5236\u7ed3\u6784\u6765\u63a7\u5236\u7a0b\u5e8f\u7684\u6267\u884c\u6d41\u7a0b\uff0c\u5305\u62ec\u6761\u4ef6\u8bed\u53e5\u3001\u5faa\u73af\u8bed\u53e5\u7b49\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">if x &gt; 5:<\/p>\n<p>    print(&quot;x is greater than 5&quot;)<\/p>\n<p>else:<\/p>\n<p>    print(&quot;x is less than or equal to 5&quot;)<\/p>\n<p>for grade in grades:<\/p>\n<p>    print(grade)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2.3 \u51fd\u6570<\/h4>\n<\/p>\n<p><p>\u51fd\u6570\u662f\u7ec4\u7ec7\u4ee3\u7801\u7684\u65b9\u5f0f\uff0c\u53ef\u4ee5\u5c06\u91cd\u590d\u7684\u4ee3\u7801\u5c01\u88c5\u8d77\u6765\uff0c\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u590d\u7528\u6027\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def greet(name):<\/p>\n<p>    print(f&quot;Hello, {name}!&quot;)<\/p>\n<p>greet(&quot;Alice&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u7406\u89e3\u7f16\u7a0b\u903b\u8f91<\/h3>\n<\/p>\n<p><h4>3.1 \u7b97\u6cd5\u548c\u6570\u636e\u7ed3\u6784<\/h4>\n<\/p>\n<p><p>\u7f16\u7a0b\u903b\u8f91\u662f\u7f16\u7a0b\u7684\u6838\u5fc3\uff0c\u6d89\u53ca\u5230\u7b97\u6cd5\u548c\u6570\u636e\u7ed3\u6784\u7684\u8bbe\u8ba1\u3002\u5e38\u7528\u7684\u6570\u636e\u7ed3\u6784\u5305\u62ec\u6570\u7ec4\u3001\u94fe\u8868\u3001\u6808\u3001\u961f\u5217\u3001\u6811\u3001\u56fe\u7b49\u3002\u5e38\u89c1\u7684\u7b97\u6cd5\u5305\u62ec\u6392\u5e8f\u3001\u641c\u7d22\u3001\u56fe\u7b97\u6cd5\u7b49\u3002\u7406\u89e3\u8fd9\u4e9b\u6982\u5ff5\u662f\u7f16\u5199\u9ad8\u6548\u7a0b\u5e8f\u7684\u57fa\u7840\u3002<\/p>\n<\/p>\n<p><h4>3.2 \u9762\u5411\u5bf9\u8c61\u7f16\u7a0b<\/h4>\n<\/p>\n<p><p>\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\uff08OOP\uff09\u662f\u4e00\u79cd\u7f16\u7a0b\u8303\u5f0f\uff0c\u5f3a\u8c03\u5bf9\u8c61\u548c\u7c7b\u7684\u6982\u5ff5\u3002Python\u652f\u6301\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\uff0c\u53ef\u4ee5\u901a\u8fc7\u5b9a\u4e49\u7c7b\u548c\u521b\u5efa\u5bf9\u8c61\u6765\u7ec4\u7ec7\u4ee3\u7801\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">class Dog:<\/p>\n<p>    def __init__(self, name):<\/p>\n<p>        self.name = name<\/p>\n<p>    def bark(self):<\/p>\n<p>        print(f&quot;{self.name} is barking&quot;)<\/p>\n<p>dog = Dog(&quot;Buddy&quot;)<\/p>\n<p>dog.bark()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u638c\u63e1\u5e38\u7528\u7684Python\u5e93\u548c\u6a21\u5757<\/h3>\n<\/p>\n<p><h4>4.1 \u6807\u51c6\u5e93<\/h4>\n<\/p>\n<p><p>Python\u81ea\u5e26\u4e86\u4e30\u5bcc\u7684\u6807\u51c6\u5e93\uff0c\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>os<\/strong>\uff1a\u63d0\u4f9b\u64cd\u4f5c\u7cfb\u7edf\u76f8\u5173\u7684\u529f\u80fd\u3002<\/li>\n<li><strong>sys<\/strong>\uff1a\u63d0\u4f9b\u4e0ePython\u89e3\u91ca\u5668\u76f8\u5173\u7684\u529f\u80fd\u3002<\/li>\n<li><strong>datetime<\/strong>\uff1a\u63d0\u4f9b\u65e5\u671f\u548c\u65f6\u95f4\u5904\u7406\u529f\u80fd\u3002<\/li>\n<\/ul>\n<p><pre><code class=\"language-python\">import os<\/p>\n<p>import sys<\/p>\n<p>import datetime<\/p>\n<p>print(os.getcwd())<\/p>\n<p>print(sys.version)<\/p>\n<p>print(datetime.datetime.now())<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>4.2 \u7b2c\u4e09\u65b9\u5e93<\/h4>\n<\/p>\n<p><p>\u9664\u4e86\u6807\u51c6\u5e93\uff0cPython\u8fd8\u6709\u5927\u91cf\u7684\u7b2c\u4e09\u65b9\u5e93\uff0c\u53ef\u4ee5\u901a\u8fc7<code>pip<\/code>\u8fdb\u884c\u5b89\u88c5\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>NumPy<\/strong>\uff1a\u7528\u4e8e\u79d1\u5b66\u8ba1\u7b97\u3002<\/li>\n<li><strong>Pandas<\/strong>\uff1a\u7528\u4e8e\u6570\u636e\u5206\u6790\u3002<\/li>\n<li><strong>Matplotlib<\/strong>\uff1a\u7528\u4e8e\u6570\u636e\u53ef\u89c6\u5316\u3002<\/li>\n<\/ul>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>import pandas as pd<\/p>\n<p>import matplotlib.pyplot as plt<\/p>\n<p>data = np.random.randn(100)<\/p>\n<p>plt.hist(data)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u8fdb\u884c\u5b9e\u9645\u9879\u76ee\u7ec3\u4e60<\/h3>\n<\/p>\n<p><h4>5.1 \u5c0f\u9879\u76ee<\/h4>\n<\/p>\n<p><p>\u901a\u8fc7\u5b8c\u6210\u5c0f\u9879\u76ee\u6765\u5de9\u56fa\u6240\u5b66\u77e5\u8bc6\u3002\u4f8b\u5982\uff0c\u7f16\u5199\u4e00\u4e2a\u8ba1\u7b97\u5668\u7a0b\u5e8f\u3001\u5b66\u751f\u6210\u7ee9\u7ba1\u7406\u7cfb\u7edf\u3001\u7b80\u5355\u7684\u7f51\u9875\u722c\u866b\u7b49\u3002\u8fd9\u4e9b\u9879\u76ee\u53ef\u4ee5\u5e2e\u52a9\u4f60\u719f\u6089Python\u7f16\u7a0b\u7684\u57fa\u672c\u6d41\u7a0b\u548c\u5e38\u7528\u6280\u5de7\u3002<\/p>\n<\/p>\n<p><h4>5.2 \u5927\u9879\u76ee<\/h4>\n<\/p>\n<p><p>\u5728\u638c\u63e1\u4e86\u57fa\u7840\u77e5\u8bc6\u548c\u5b8c\u6210\u4e86\u4e00\u4e9b\u5c0f\u9879\u76ee\u540e\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u8fdb\u884c\u66f4\u590d\u6742\u7684\u5927\u9879\u76ee\u3002\u4f8b\u5982\uff0c\u5f00\u53d1\u4e00\u4e2a\u5b8c\u6574\u7684Web\u5e94\u7528\u3001\u5b9e\u73b0\u4e00\u4e2a<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u6a21\u578b\u3001\u8fdb\u884c\u6570\u636e\u5206\u6790\u548c\u53ef\u89c6\u5316\u7b49\u3002\u8fd9\u4e9b\u9879\u76ee\u53ef\u4ee5\u5e2e\u52a9\u4f60\u6df1\u5165\u7406\u89e3Python\u7f16\u7a0b\u7684\u9ad8\u7ea7\u6982\u5ff5\u548c\u5b9e\u6218\u6280\u5de7\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u4e0d\u65ad\u8c03\u8bd5\u548c\u4f18\u5316\u7a0b\u5e8f<\/h3>\n<\/p>\n<p><h4>6.1 \u8c03\u8bd5\u6280\u5de7<\/h4>\n<\/p>\n<p><p>\u8c03\u8bd5\u662f\u7f16\u7a0b\u4e2d\u4e0d\u53ef\u907f\u514d\u7684\u73af\u8282\u3002\u5e38\u7528\u7684\u8c03\u8bd5\u6280\u5de7\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u4f7f\u7528print\u8bed\u53e5<\/strong>\uff1a\u901a\u8fc7\u5728\u4ee3\u7801\u4e2d\u63d2\u5165<code>print<\/code>\u8bed\u53e5\u6765\u8f93\u51fa\u53d8\u91cf\u7684\u503c\uff0c\u68c0\u67e5\u7a0b\u5e8f\u7684\u6267\u884c\u60c5\u51b5\u3002<\/li>\n<li><strong>\u4f7f\u7528\u8c03\u8bd5\u5de5\u5177<\/strong>\uff1aIDE\u901a\u5e38\u63d0\u4f9b\u8c03\u8bd5\u5de5\u5177\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u65ad\u70b9\u3001\u5355\u6b65\u6267\u884c\u3001\u67e5\u770b\u53d8\u91cf\u503c\u7b49\u3002<\/li>\n<\/ul>\n<p><h4>6.2 \u6027\u80fd\u4f18\u5316<\/h4>\n<\/p>\n<p><p>\u6027\u80fd\u4f18\u5316\u662f\u63d0\u9ad8\u7a0b\u5e8f\u6548\u7387\u7684\u91cd\u8981\u73af\u8282\u3002\u5e38\u7528\u7684\u6027\u80fd\u4f18\u5316\u6280\u5de7\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u51cf\u5c11\u4e0d\u5fc5\u8981\u7684\u8ba1\u7b97<\/strong>\uff1a\u907f\u514d\u91cd\u590d\u8ba1\u7b97\u76f8\u540c\u7684\u7ed3\u679c\u3002<\/li>\n<li><strong>\u4f7f\u7528\u9ad8\u6548\u7684\u6570\u636e\u7ed3\u6784<\/strong>\uff1a\u9009\u62e9\u5408\u9002\u7684\u6570\u636e\u7ed3\u6784\u6765\u5b58\u50a8\u548c\u5904\u7406\u6570\u636e\u3002<\/li>\n<li><strong>\u5e76\u884c\u8ba1\u7b97<\/strong>\uff1a\u5229\u7528\u591a\u7ebf\u7a0b\u6216\u591a\u8fdb\u7a0b\u6765\u63d0\u9ad8\u8ba1\u7b97\u6548\u7387\u3002<\/li>\n<\/ul>\n<p><p>\u901a\u8fc7\u4e0d\u65ad\u5730\u8c03\u8bd5\u548c\u4f18\u5316\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7684\u8d28\u91cf\u548c\u8fd0\u884c\u6548\u7387\u3002<\/p>\n<\/p>\n<p><h3>\u4e03\u3001\u4ee3\u7801\u89c4\u8303\u548c\u7248\u672c\u63a7\u5236<\/h3>\n<\/p>\n<p><h4>7.1 \u4ee3\u7801\u89c4\u8303<\/h4>\n<\/p>\n<p><p>\u9075\u5faa\u4ee3\u7801\u89c4\u8303\u53ef\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u7ef4\u62a4\u6027\u3002\u5e38\u89c1\u7684\u4ee3\u7801\u89c4\u8303\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>PEP 8<\/strong>\uff1aPython\u7684\u5b98\u65b9\u4ee3\u7801\u98ce\u683c\u6307\u5357\uff0c\u8be6\u7ec6\u89c4\u5b9a\u4e86\u4ee3\u7801\u7684\u683c\u5f0f\u548c\u547d\u540d\u89c4\u5219\u3002<\/li>\n<li><strong>Docstring<\/strong>\uff1a\u5728\u51fd\u6570\u3001\u7c7b\u3001\u6a21\u5757\u4e2d\u6dfb\u52a0\u6587\u6863\u5b57\u7b26\u4e32\uff0c\u65b9\u4fbf\u5176\u4ed6\u5f00\u53d1\u8005\u7406\u89e3\u4ee3\u7801\u7684\u529f\u80fd\u548c\u7528\u6cd5\u3002<\/li>\n<\/ul>\n<p><h4>7.2 \u7248\u672c\u63a7\u5236<\/h4>\n<\/p>\n<p><p>\u7248\u672c\u63a7\u5236\u662f\u7ba1\u7406\u4ee3\u7801\u7248\u672c\u7684\u91cd\u8981\u5de5\u5177\u3002\u5e38\u7528\u7684\u7248\u672c\u63a7\u5236\u7cfb\u7edf\u5305\u62ecGit\u3001SVN\u7b49\u3002\u901a\u8fc7\u4f7f\u7528\u7248\u672c\u63a7\u5236\uff0c\u53ef\u4ee5\u8bb0\u5f55\u4ee3\u7801\u7684\u5386\u53f2\u7248\u672c\uff0c\u65b9\u4fbf\u534f\u540c\u5f00\u53d1\u548c\u4ee3\u7801\u56de\u6eda\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\"># Git\u5e38\u7528\u547d\u4ee4<\/p>\n<p>git init              # \u521d\u59cb\u5316\u4ed3\u5e93<\/p>\n<p>git add .             # \u6dfb\u52a0\u6587\u4ef6\u5230\u6682\u5b58\u533a<\/p>\n<p>git commit -m &quot;message&quot; # \u63d0\u4ea4\u6587\u4ef6\u5230\u7248\u672c\u5e93<\/p>\n<p>git push              # \u63a8\u9001\u4ee3\u7801\u5230\u8fdc\u7a0b\u4ed3\u5e93<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516b\u3001\u5b66\u4e60\u8d44\u6e90\u548c\u793e\u533a<\/h3>\n<\/p>\n<p><h4>8.1 \u5728\u7ebf\u6559\u7a0b<\/h4>\n<\/p>\n<p><p>\u5b66\u4e60Python\u7f16\u7a0b\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u9014\u5f84\u83b7\u5f97\u5b66\u4e60\u8d44\u6e90\u3002\u5e38\u89c1\u7684\u5728\u7ebf\u6559\u7a0b\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u5b98\u65b9\u6587\u6863<\/strong>\uff1aPython\u5b98\u65b9\u7f51\u7ad9\u63d0\u4f9b\u4e86\u8be6\u7ec6\u7684\u6587\u6863\u548c\u6559\u7a0b\u3002<\/li>\n<li><strong>\u5728\u7ebf\u8bfe\u7a0b<\/strong>\uff1a\u5982Coursera\u3001Udemy\u3001edX\u7b49\u5e73\u53f0\u63d0\u4f9b\u4e86\u5927\u91cf\u7684Python\u8bfe\u7a0b\u3002<\/li>\n<li><strong>\u535a\u5ba2\u548c\u8bba\u575b<\/strong>\uff1a\u5982Stack Overflow\u3001GitHub\u7b49\u5e73\u53f0\u6709\u8bb8\u591a\u5f00\u53d1\u8005\u5206\u4eab\u7684\u7ecf\u9a8c\u548c\u6559\u7a0b\u3002<\/li>\n<\/ul>\n<p><h4>8.2 \u4e66\u7c4d<\/h4>\n<\/p>\n<p><p>\u9664\u4e86\u5728\u7ebf\u8d44\u6e90\uff0c\u9605\u8bfb\u76f8\u5173\u4e66\u7c4d\u4e5f\u662f\u5b66\u4e60Python\u7f16\u7a0b\u7684\u91cd\u8981\u9014\u5f84\u3002\u5e38\u89c1\u7684Python\u4e66\u7c4d\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u300aPython\u7f16\u7a0b\uff1a\u4ece\u5165\u95e8\u5230\u5b9e\u8df5\u300b<\/strong>\uff1a\u9002\u5408\u521d\u5b66\u8005\u5165\u95e8\u3002<\/li>\n<li><strong>\u300a\u6d41\u7545\u7684Python\u300b<\/strong>\uff1a\u9002\u5408\u6709\u4e00\u5b9a\u57fa\u7840\u7684\u5f00\u53d1\u8005\u6df1\u5165\u5b66\u4e60\u3002<\/li>\n<li><strong>\u300aPython Cookbook\u300b<\/strong>\uff1a\u63d0\u4f9b\u4e86\u5927\u91cf\u5b9e\u7528\u7684\u4ee3\u7801\u793a\u4f8b\u548c\u6280\u5de7\u3002<\/li>\n<\/ul>\n<p><p>\u901a\u8fc7\u5229\u7528\u8fd9\u4e9b\u5b66\u4e60\u8d44\u6e90\uff0c\u53ef\u4ee5\u4e0d\u65ad\u63d0\u5347\u81ea\u5df1\u7684\u7f16\u7a0b\u80fd\u529b\u3002<\/p>\n<\/p>\n<p><h3>\u4e5d\u3001\u9879\u76ee\u5b9e\u8df5\u6848\u4f8b<\/h3>\n<\/p>\n<p><h4>9.1 \u7b80\u5355\u7684\u7f51\u9875\u722c\u866b<\/h4>\n<\/p>\n<p><p>\u7f16\u5199\u4e00\u4e2a\u7b80\u5355\u7684\u7f51\u9875\u722c\u866b\uff0c\u6293\u53d6\u67d0\u4e2a\u7f51\u7ad9\u7684\u5185\u5bb9\u3002\u4f8b\u5982\uff0c\u6293\u53d6\u67d0\u4e2a\u65b0\u95fb\u7f51\u7ad9\u7684\u6807\u9898\u548c\u94fe\u63a5\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<p>from bs4 import BeautifulSoup<\/p>\n<p>def get_news(url):<\/p>\n<p>    response = requests.get(url)<\/p>\n<p>    soup = BeautifulSoup(response.content, &quot;html.parser&quot;)<\/p>\n<p>    headlines = soup.find_all(&quot;h2&quot;)<\/p>\n<p>    for headline in headlines:<\/p>\n<p>        print(headline.text.strip())<\/p>\n<p>get_news(&quot;https:\/\/news.ycombinator.com\/&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>9.2 \u6570\u636e\u5206\u6790\u9879\u76ee<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528Pandas\u548cMatplotlib\u8fdb\u884c\u6570\u636e\u5206\u6790\u548c\u53ef\u89c6\u5316\u3002\u4f8b\u5982\uff0c\u5206\u6790\u67d0\u4e2a\u6570\u636e\u96c6\u7684\u57fa\u672c\u7edf\u8ba1\u4fe1\u606f\uff0c\u5e76\u7ed8\u5236\u56fe\u8868\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>import matplotlib.pyplot as plt<\/p>\n<h2><strong>\u8bfb\u53d6\u6570\u636e<\/strong><\/h2>\n<p>data = pd.read_csv(&quot;data.csv&quot;)<\/p>\n<h2><strong>\u57fa\u672c\u7edf\u8ba1\u4fe1\u606f<\/strong><\/h2>\n<p>print(data.describe())<\/p>\n<h2><strong>\u7ed8\u5236\u56fe\u8868<\/strong><\/h2>\n<p>data[&quot;column_name&quot;].plot(kind=&quot;hist&quot;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u5341\u3001\u6301\u7eed\u5b66\u4e60\u548c\u5b9e\u8df5<\/h3>\n<\/p>\n<p><p>\u7f16\u7a0b\u662f\u4e00\u9879\u9700\u8981\u6301\u7eed\u5b66\u4e60\u548c\u5b9e\u8df5\u7684\u6280\u80fd\u3002\u901a\u8fc7\u4e0d\u65ad\u5730\u5b66\u4e60\u65b0\u77e5\u8bc6\u3001\u5c1d\u8bd5\u65b0\u6280\u672f\u3001\u53c2\u4e0e\u5f00\u6e90\u9879\u76ee\uff0c\u53ef\u4ee5\u4e0d\u65ad\u63d0\u5347\u81ea\u5df1\u7684\u7f16\u7a0b\u80fd\u529b\u3002<\/p>\n<\/p>\n<p><h4>10.1 \u5b66\u4e60\u65b0\u6280\u672f<\/h4>\n<\/p>\n<p><p>Python\u751f\u6001\u7cfb\u7edf\u975e\u5e38\u4e30\u5bcc\uff0c\u5305\u542b\u4e86\u5927\u91cf\u7684\u5e93\u548c\u6846\u67b6\u3002\u4e0d\u65ad\u5b66\u4e60\u548c\u638c\u63e1\u65b0\u6280\u672f\uff0c\u53ef\u4ee5\u62d3\u5bbd\u81ea\u5df1\u7684\u77e5\u8bc6\u9762\u548c\u6280\u80fd\u3002\u4f8b\u5982\uff0c\u5b66\u4e60Django\u6216Flask\u8fdb\u884cWeb\u5f00\u53d1\uff0c\u5b66\u4e60TensorFlow\u6216PyTorch\u8fdb\u884c\u673a\u5668\u5b66\u4e60\u7b49\u3002<\/p>\n<\/p>\n<p><h4>10.2 \u53c2\u4e0e\u5f00\u6e90\u9879\u76ee<\/h4>\n<\/p>\n<p><p>\u53c2\u4e0e\u5f00\u6e90\u9879\u76ee\u662f\u63d0\u5347\u7f16\u7a0b\u80fd\u529b\u7684\u91cd\u8981\u9014\u5f84\u3002\u901a\u8fc7\u53c2\u4e0e\u5f00\u6e90\u9879\u76ee\uff0c\u53ef\u4ee5\u63a5\u89e6\u5230\u771f\u5b9e\u7684\u9879\u76ee\uff0c\u5b66\u4e60\u5230\u5176\u4ed6\u5f00\u53d1\u8005\u7684\u7f16\u7a0b\u6280\u5de7\u548c\u7ecf\u9a8c\u3002\u6b64\u5916\uff0c\u8fd8\u53ef\u4ee5\u901a\u8fc7\u8d21\u732e\u4ee3\u7801\u3001\u63d0\u4ea4\u95ee\u9898\u3001\u53c2\u4e0e\u8ba8\u8bba\u7b49\u65b9\u5f0f\uff0c\u4e0e\u5176\u4ed6\u5f00\u53d1\u8005\u8fdb\u884c\u4ea4\u6d41\u548c\u5408\u4f5c\u3002<\/p>\n<\/p>\n<p><p>\u603b\u4e4b\uff0c\u7f16\u5199Python\u7a0b\u5e8f\u9700\u8981\u9009\u62e9\u5408\u9002\u7684\u5f00\u53d1\u73af\u5883\u3001\u5b66\u4e60\u57fa\u7840\u8bed\u6cd5\u3001\u7406\u89e3\u7f16\u7a0b\u903b\u8f91\u3001\u638c\u63e1\u5e38\u7528\u5e93\u548c\u6a21\u5757\u3001\u8fdb\u884c\u5b9e\u9645\u9879\u76ee\u7ec3\u4e60\u3001\u4e0d\u65ad\u8c03\u8bd5\u548c\u4f18\u5316\u7a0b\u5e8f\u3001\u9075\u5faa\u4ee3\u7801\u89c4\u8303\u548c\u7248\u672c\u63a7\u5236\u3001\u5229\u7528\u5b66\u4e60\u8d44\u6e90\u548c\u793e\u533a\u3001\u8fdb\u884c\u9879\u76ee\u5b9e\u8df5\u3001\u6301\u7eed\u5b66\u4e60\u548c\u5b9e\u8df5\u3002\u901a\u8fc7\u4e0d\u65ad\u5730\u5b66\u4e60\u548c\u5b9e\u8df5\uff0c\u53ef\u4ee5\u4e0d\u65ad\u63d0\u5347\u81ea\u5df1\u7684\u7f16\u7a0b\u80fd\u529b\uff0c\u6210\u4e3a\u4e00\u540d\u4f18\u79c0\u7684Python\u5f00\u53d1\u8005\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5f00\u59cb\u5b66\u4e60Python\u7f16\u7a0b\uff1f<\/strong><br \/>\u5b66\u4e60Python\u7f16\u7a0b\u7684\u7b2c\u4e00\u6b65\u662f\u9009\u62e9\u5408\u9002\u7684\u5b66\u4e60\u8d44\u6e90\u3002\u53ef\u4ee5\u4ece\u5728\u7ebf\u8bfe\u7a0b\u3001\u4e66\u7c4d\u6216\u89c6\u9891\u6559\u7a0b\u5165\u624b\u3002\u9009\u62e9\u9002\u5408\u4f60\u5b66\u4e60\u98ce\u683c\u7684\u6750\u6599\uff0c\u5e76\u786e\u4fdd\u5b83\u4eec\u8986\u76d6\u57fa\u7840\u6982\u5ff5\uff0c\u5982\u53d8\u91cf\u3001\u6570\u636e\u7c7b\u578b\u3001\u63a7\u5236\u7ed3\u6784\u548c\u51fd\u6570\u7b49\u3002\u6b64\u5916\uff0c\u5b9e\u8df5\u662f\u5173\u952e\uff0c\u5efa\u8bae\u901a\u8fc7\u5b8c\u6210\u5c0f\u9879\u76ee\u6216\u7f16\u5199\u7b80\u5355\u7684\u811a\u672c\u6765\u5de9\u56fa\u6240\u5b66\u77e5\u8bc6\u3002<\/p>\n<p><strong>\u6211\u9700\u8981\u54ea\u4e9b\u5de5\u5177\u6765\u7f16\u5199Python\u7a0b\u5e8f\uff1f<\/strong><br \/>\u7f16\u5199Python\u7a0b\u5e8f\u6240\u9700\u7684\u5de5\u5177\u4e3b\u8981\u5305\u62ecPython\u89e3\u91ca\u5668\u548c\u4e00\u4e2a\u4ee3\u7801\u7f16\u8f91\u5668\u3002\u53ef\u4ee5\u4ecePython\u5b98\u7f51\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684Python\uff0c\u540c\u65f6\u9009\u62e9\u4e00\u4e2a\u4f60\u559c\u6b22\u7684\u4ee3\u7801\u7f16\u8f91\u5668\uff0c\u5982Visual Studio Code\u3001PyCharm\u6216Sublime Text\u3002\u8fd9\u4e9b\u5de5\u5177\u80fd\u63d0\u4f9b\u8bed\u6cd5\u9ad8\u4eae\u3001\u4ee3\u7801\u81ea\u52a8\u5b8c\u6210\u7b49\u529f\u80fd\uff0c\u5e2e\u52a9\u4f60\u66f4\u9ad8\u6548\u5730\u7f16\u5199\u4ee3\u7801\u3002<\/p>\n<p><strong>\u5982\u4f55\u8c03\u8bd5\u6211\u7f16\u5199\u7684Python\u7a0b\u5e8f\uff1f<\/strong><br \/>\u8c03\u8bd5Python\u7a0b\u5e8f\u53ef\u4ee5\u901a\u8fc7\u51e0\u79cd\u65b9\u5f0f\u8fdb\u884c\u3002\u4f7f\u7528\u5185\u7f6e\u7684<code>print()<\/code>\u51fd\u6570\u6765\u8f93\u51fa\u53d8\u91cf\u503c\uff0c\u5e2e\u52a9\u4f60\u7406\u89e3\u7a0b\u5e8f\u7684\u6267\u884c\u6d41\u7a0b\u548c\u72b6\u6001\u3002Python\u8fd8\u63d0\u4f9b\u4e86<code>pdb<\/code>\u6a21\u5757\uff0c\u53ef\u4ee5\u5728\u4ee3\u7801\u4e2d\u8bbe\u7f6e\u65ad\u70b9\uff0c\u9010\u884c\u6267\u884c\u5e76\u68c0\u67e5\u53d8\u91cf\u3002\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u4e2d\u7684\u8c03\u8bd5\u5de5\u5177\u4e5f\u662f\u4e00\u79cd\u9ad8\u6548\u7684\u65b9\u6cd5\uff0c\u5b83\u53ef\u4ee5\u63d0\u4f9b\u66f4\u76f4\u89c2\u7684\u8c03\u8bd5\u4f53\u9a8c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u5982\u4f55\u81ea\u5df1\u5199\u7a0b\u5e8f\uff1f \u8981\u81ea\u5df1\u7f16\u5199Python\u7a0b\u5e8f\uff0c\u9996\u5148\u9700\u8981\u9009\u62e9\u5408\u9002\u7684\u5f00\u53d1\u73af\u5883\u3001\u5b66\u4e60Python\u57fa\u7840\u8bed\u6cd5 [&hellip;]","protected":false},"author":3,"featured_media":1157784,"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\/1157780"}],"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=1157780"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1157780\/revisions"}],"predecessor-version":[{"id":1157785,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1157780\/revisions\/1157785"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1157784"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1157780"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1157780"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1157780"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}