{"id":926504,"date":"2024-12-26T15:52:26","date_gmt":"2024-12-26T07:52:26","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/926504.html"},"modified":"2024-12-26T15:52:28","modified_gmt":"2024-12-26T07:52:28","slug":"%e5%a6%82%e4%bd%95%e6%8c%89%e7%85%a7python","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/926504.html","title":{"rendered":"\u5982\u4f55\u6309\u7167python"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25063100\/f6c6ebab-24e1-4ba9-a11e-e2cedb00ca97.webp\" alt=\"\u5982\u4f55\u6309\u7167python\" \/><\/p>\n<p><p> <strong>\u8981\u6309\u7167Python\u8fdb\u884c\u7f16\u7a0b\uff0c\u9700\u8981\u4e86\u89e3Python\u7684\u57fa\u7840\u8bed\u6cd5\u3001\u5b89\u88c5Python\u73af\u5883\u3001\u4f7f\u7528Python\u7f16\u8f91\u5668\u6216IDE\u3001\u7f16\u5199\u548c\u6267\u884cPython\u4ee3\u7801\u3001\u4ee5\u53ca\u5b66\u4e60Python\u5e93\u548c\u6a21\u5757\u3002<\/strong>Python\u662f\u4e00\u79cd\u9ad8\u5c42\u6b21\u7684\u3001\u89e3\u91ca\u578b\u7684\u7f16\u7a0b\u8bed\u8a00\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8e\u6570\u636e\u5206\u6790\u3001<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u3001Web\u5f00\u53d1\u7b49\u9886\u57df\u3002\u4e3a\u4e86\u5f00\u59cb\u4f7f\u7528Python\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5Python\u89e3\u91ca\u5668\uff0c\u53ef\u4ee5\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u5b89\u88c5\u3002\u63a5\u4e0b\u6765\uff0c\u9009\u62e9\u4e00\u4e2a\u5408\u9002\u7684\u7f16\u8f91\u5668\u6216\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\uff0c\u5982PyCharm\u3001VSCode\u6216Jupyter Notebook\uff0c\u4ee5\u4fbf\u66f4\u9ad8\u6548\u5730\u7f16\u5199\u548c\u8fd0\u884c\u4ee3\u7801\u3002\u719f\u6089Python\u7684\u57fa\u7840\u8bed\u6cd5\u662f\u5173\u952e\uff0c\u5305\u62ec\u53d8\u91cf\u3001\u6570\u636e\u7c7b\u578b\u3001\u63a7\u5236\u7ed3\u6784\uff08\u5982\u5faa\u73af\u548c\u6761\u4ef6\u8bed\u53e5\uff09\u3001\u51fd\u6570\u3001\u7c7b\u548c\u5f02\u5e38\u5904\u7406\u7b49\u3002\u540c\u65f6\uff0c\u4e86\u89e3Python\u7684\u6807\u51c6\u5e93\u548c\u7b2c\u4e09\u65b9\u5e93\u53ef\u4ee5\u5927\u5927\u63d0\u9ad8\u7f16\u7a0b\u6548\u7387\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u5b89\u88c5Python\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u7f16\u5199Python\u4ee3\u7801\u4e4b\u524d\uff0c\u60a8\u9700\u8981\u786e\u4fdd\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5\u4e86Python\u73af\u5883\u3002Python\u7684\u5b89\u88c5\u8fc7\u7a0b\u975e\u5e38\u7b80\u5355\uff0c\u53ef\u4ee5\u5728Python\u5b98\u65b9\u7f51\u7ad9\uff08python.org\uff09\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684Python\u5b89\u88c5\u5305\u3002\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u53ef\u4ee5\u9009\u62e9\u662f\u5426\u5b89\u88c5pip\uff08Python\u5305\u7ba1\u7406\u5de5\u5177\uff09\u548cIDLE\uff08Python\u81ea\u5e26\u7684\u7b80\u5355IDE\uff09\uff0c\u5efa\u8bae\u9009\u62e9\u5b89\u88c5\u4ee5\u4fbf\u540e\u7eed\u4f7f\u7528\u3002<\/p>\n<\/p>\n<p><h4>1.1\u3001\u9009\u62e9\u5408\u9002\u7684\u7248\u672c<\/h4>\n<\/p>\n<p><p>Python\u6709\u4e24\u4e2a\u4e3b\u8981\u7248\u672c\uff1aPython 2\u548cPython 3\u3002Python 2\u5df2\u7ecf\u57282020\u5e74\u505c\u6b62\u7ef4\u62a4\uff0c\u6240\u4ee5\u63a8\u8350\u4f7f\u7528Python 3\u3002\u4e0b\u8f7d\u65f6\u8bf7\u6ce8\u610f\u9009\u62e9\u4e0e\u64cd\u4f5c\u7cfb\u7edf\uff08Windows\u3001macOS\u3001Linux\uff09\u517c\u5bb9\u7684\u7248\u672c\u3002<\/p>\n<\/p>\n<p><h4>1.2\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/h4>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u5b89\u88c5Python\u65f6\u53ef\u4ee5\u9009\u62e9\u81ea\u52a8\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u8fd9\u6837\u53ef\u4ee5\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u76f4\u63a5\u4f7f\u7528Python\u547d\u4ee4\u3002\u5728macOS\u548cLinux\u7cfb\u7edf\u4e2d\uff0c\u901a\u5e38\u9700\u8981\u624b\u52a8\u7f16\u8f91<code>~\/.bashrc<\/code>\u6216<code>~\/.bash_profile<\/code>\u6587\u4ef6\uff0c\u5c06Python\u5b89\u88c5\u8def\u5f84\u6dfb\u52a0\u5230<code>PATH<\/code>\u73af\u5883\u53d8\u91cf\u4e2d\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u9009\u62e9Python\u7f16\u8f91\u5668\u6216IDE<\/h3>\n<\/p>\n<p><p>\u9009\u62e9\u5408\u9002\u7684\u7f16\u8f91\u5668\u6216IDE\u5bf9\u4e8e\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u81f3\u5173\u91cd\u8981\u3002\u4e0d\u540c\u7684\u7f16\u8f91\u5668\u548cIDE\u63d0\u4f9b\u4e0d\u540c\u7684\u529f\u80fd\u548c\u7279\u6027\uff0c\u9002\u5408\u4e0d\u540c\u7684\u9700\u6c42\u548c\u4e60\u60ef\u3002<\/p>\n<\/p>\n<p><h4>2.1\u3001\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09<\/h4>\n<\/p>\n<p><p>PyCharm\u662fJetBr<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>ns\u516c\u53f8\u5f00\u53d1\u7684\u4e00\u6b3e\u529f\u80fd\u5f3a\u5927\u7684IDE\uff0c\u9002\u5408\u5927\u4e2d\u578b\u9879\u76ee\u5f00\u53d1\uff0c\u63d0\u4f9b\u4e86\u4ee3\u7801\u8865\u5168\u3001\u8c03\u8bd5\u3001\u6d4b\u8bd5\u3001\u7248\u672c\u63a7\u5236\u7b49\u529f\u80fd\u3002VSCode\u662f\u5fae\u8f6f\u63a8\u51fa\u7684\u4e00\u6b3e\u8f7b\u91cf\u7ea7\u7f16\u8f91\u5668\uff0c\u652f\u6301Python\u63d2\u4ef6\uff0c\u9002\u5408\u5feb\u901f\u5f00\u53d1\u548c\u5c0f\u578b\u9879\u76ee\u3002Jupyter Notebook\u662f\u4e00\u6b3e\u57fa\u4e8eWeb\u7684\u4ea4\u4e92\u5f0f\u5f00\u53d1\u73af\u5883\uff0c\u9002\u5408\u6570\u636e\u5206\u6790\u548c\u673a\u5668\u5b66\u4e60\u3002<\/p>\n<\/p>\n<p><h4>2.2\u3001\u6587\u672c\u7f16\u8f91\u5668<\/h4>\n<\/p>\n<p><p>Sublime Text\u548cAtom\u662f\u4e24\u6b3e\u6d41\u884c\u7684\u6587\u672c\u7f16\u8f91\u5668\uff0c\u9002\u5408\u7f16\u5199\u7b80\u5355\u7684Python\u811a\u672c\uff0c\u652f\u6301\u591a\u79cd\u63d2\u4ef6\u548c\u4e3b\u9898\uff0c\u53ef\u4ee5\u6ee1\u8db3\u4e2a\u6027\u5316\u9700\u6c42\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u5b66\u4e60Python\u57fa\u7840\u8bed\u6cd5<\/h3>\n<\/p>\n<p><p>\u5b66\u4e60Python\u7684\u57fa\u7840\u8bed\u6cd5\u662f\u638c\u63e1\u8fd9\u95e8\u8bed\u8a00\u7684\u5173\u952e\uff0c\u8fd9\u5305\u62ec\u53d8\u91cf\u3001\u6570\u636e\u7c7b\u578b\u3001\u8fd0\u7b97\u7b26\u3001\u63a7\u5236\u7ed3\u6784\u3001\u51fd\u6570\u3001\u7c7b\u548c\u6a21\u5757\u7b49\u3002<\/p>\n<\/p>\n<p><h4>3.1\u3001\u53d8\u91cf\u548c\u6570\u636e\u7c7b\u578b<\/h4>\n<\/p>\n<p><p>Python\u662f\u4e00\u79cd\u52a8\u6001\u7c7b\u578b\u8bed\u8a00\uff0c\u53d8\u91cf\u4e0d\u9700\u8981\u58f0\u660e\u7c7b\u578b\u3002\u5e38\u89c1\u7684\u6570\u636e\u7c7b\u578b\u5305\u62ec\u6574\u6570\uff08int\uff09\u3001\u6d6e\u70b9\u6570\uff08float\uff09\u3001\u5b57\u7b26\u4e32\uff08str\uff09\u3001\u5e03\u5c14\u503c\uff08bool\uff09\u548c\u5217\u8868\uff08list\uff09\u7b49\u3002\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u51fd\u6570<code>type()<\/code>\u67e5\u770b\u53d8\u91cf\u7684\u7c7b\u578b\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">x = 10<\/p>\n<p>y = 3.14<\/p>\n<p>name = &quot;Python&quot;<\/p>\n<p>is_valid = True<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3.2\u3001\u8fd0\u7b97\u7b26<\/h4>\n<\/p>\n<p><p>Python\u652f\u6301\u591a\u79cd\u8fd0\u7b97\u7b26\uff0c\u5305\u62ec\u7b97\u672f\u8fd0\u7b97\u7b26\uff08+\u3001-\u3001*\u3001\/\u3001%\uff09\u3001\u6bd4\u8f83\u8fd0\u7b97\u7b26\uff08==\u3001!=\u3001&gt;\u3001&lt;\uff09\u548c\u903b\u8f91\u8fd0\u7b97\u7b26\uff08and\u3001or\u3001not\uff09\u7b49\u3002\u8fd9\u4e9b\u8fd0\u7b97\u7b26\u53ef\u4ee5\u7528\u4e8e\u5bf9\u53d8\u91cf\u8fdb\u884c\u5404\u79cd\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">a = 5<\/p>\n<p>b = 3<\/p>\n<p>print(a + b)  # \u8f93\u51fa8<\/p>\n<p>print(a &gt; b)  # \u8f93\u51faTrue<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3.3\u3001\u63a7\u5236\u7ed3\u6784<\/h4>\n<\/p>\n<p><p>\u63a7\u5236\u7ed3\u6784\u7528\u4e8e\u63a7\u5236\u7a0b\u5e8f\u7684\u6267\u884c\u6d41\u7a0b\u3002Python\u63d0\u4f9b\u4e86if-else\u6761\u4ef6\u8bed\u53e5\u3001for\u548cwhile\u5faa\u73af\u8bed\u53e5\u4ee5\u53cabreak\u548ccontinue\u63a7\u5236\u5faa\u73af\u7684\u6267\u884c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># if-else\u8bed\u53e5<\/p>\n<p>if a &gt; b:<\/p>\n<p>    print(&quot;a is greater than b&quot;)<\/p>\n<p>else:<\/p>\n<p>    print(&quot;a is not greater than b&quot;)<\/p>\n<h2><strong>for\u5faa\u73af<\/strong><\/h2>\n<p>for i in range(5):<\/p>\n<p>    print(i)<\/p>\n<h2><strong>while\u5faa\u73af<\/strong><\/h2>\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<p><h3>\u56db\u3001\u6a21\u5757\u548c\u5e93\u7684\u4f7f\u7528<\/h3>\n<\/p>\n<p><p>Python\u7684\u5f3a\u5927\u4e4b\u5904\u5728\u4e8e\u5176\u4e30\u5bcc\u7684\u6807\u51c6\u5e93\u548c\u7b2c\u4e09\u65b9\u5e93\uff0c\u8fd9\u4e9b\u5e93\u63d0\u4f9b\u4e86\u5927\u91cf\u7684\u529f\u80fd\uff0c\u4f7f\u5f00\u53d1\u8005\u80fd\u591f\u5feb\u901f\u5b9e\u73b0\u590d\u6742\u7684\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><h4>4.1\u3001\u5bfc\u5165\u6a21\u5757<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528<code>import<\/code>\u8bed\u53e5\u5bfc\u5165Python\u6807\u51c6\u5e93\u4e2d\u7684\u6a21\u5757\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528<code>pip<\/code>\u5b89\u88c5\u548c\u5bfc\u5165\u7b2c\u4e09\u65b9\u5e93\u3002\u4f8b\u5982\uff0c\u4f7f\u7528<code>math<\/code>\u6a21\u5757\u8fdb\u884c\u6570\u5b66\u8fd0\u7b97\uff0c\u4f7f\u7528<code>datetime<\/code>\u6a21\u5757\u5904\u7406\u65e5\u671f\u548c\u65f6\u95f4\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<p>print(math.sqrt(16))  # \u8f93\u51fa4.0<\/p>\n<p>import datetime<\/p>\n<p>now = datetime.datetime.now()<\/p>\n<p>print(now)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>4.2\u3001\u5e38\u7528\u7b2c\u4e09\u65b9\u5e93<\/h4>\n<\/p>\n<ul>\n<li><strong>NumPy<\/strong>\uff1a\u7528\u4e8e\u6570\u503c\u8ba1\u7b97\u548c\u6570\u7ec4\u64cd\u4f5c\u3002<\/li>\n<li><strong>Pandas<\/strong>\uff1a\u7528\u4e8e\u6570\u636e\u5206\u6790\u548c\u6570\u636e\u5904\u7406\u3002<\/li>\n<li><strong>Matplotlib<\/strong>\uff1a\u7528\u4e8e\u6570\u636e\u53ef\u89c6\u5316\u3002<\/li>\n<li><strong>Requests<\/strong>\uff1a\u7528\u4e8e\u53d1\u9001HTTP\u8bf7\u6c42\u3002<\/li>\n<li><strong>Flask\/Django<\/strong>\uff1a\u7528\u4e8eWeb\u5f00\u53d1\u3002<\/li>\n<\/ul>\n<p><h3>\u4e94\u3001\u7f16\u5199\u548c\u6267\u884cPython\u4ee3\u7801<\/h3>\n<\/p>\n<p><p>\u7f16\u5199\u548c\u6267\u884cPython\u4ee3\u7801\u662f\u5b66\u4e60Python\u7684\u6700\u7ec8\u76ee\u7684\uff0c\u901a\u8fc7\u7f16\u5199\u4ee3\u7801\u53ef\u4ee5\u5c06\u6240\u5b66\u7684\u77e5\u8bc6\u5e94\u7528\u5230\u5b9e\u9645\u9879\u76ee\u4e2d\u3002<\/p>\n<\/p>\n<p><h4>5.1\u3001\u7f16\u5199Python\u811a\u672c<\/h4>\n<\/p>\n<p><p>Python\u811a\u672c\u662f\u4ee5<code>.py<\/code>\u4e3a\u6269\u5c55\u540d\u7684\u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528\u4efb\u4f55\u6587\u672c\u7f16\u8f91\u5668\u7f16\u5199\u3002\u7f16\u5199\u811a\u672c\u65f6\u9700\u8981\u6ce8\u610f\u4ee3\u7801\u7684\u7f29\u8fdb\uff0cPython\u4f7f\u7528\u7f29\u8fdb\u6765\u6807\u8bc6\u4ee3\u7801\u5757\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># hello.py<\/p>\n<p>def greet(name):<\/p>\n<p>    print(f&quot;Hello, {name}!&quot;)<\/p>\n<p>greet(&quot;World&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>5.2\u3001\u6267\u884cPython\u811a\u672c<\/h4>\n<\/p>\n<p><p>\u5728\u547d\u4ee4\u884c\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>python<\/code>\u547d\u4ee4\u6267\u884cPython\u811a\u672c\u3002\u4f8b\u5982\uff0c\u6267\u884c<code>hello.py<\/code>\u811a\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python hello.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6b64\u5916\uff0c\u5927\u591a\u6570IDE\u548c\u7f16\u8f91\u5668\u4e5f\u63d0\u4f9b\u4e86\u76f4\u63a5\u8fd0\u884cPython\u4ee3\u7801\u7684\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u8c03\u8bd5\u548c\u6d4b\u8bd5Python\u4ee3\u7801<\/h3>\n<\/p>\n<p><p>\u8c03\u8bd5\u548c\u6d4b\u8bd5\u662f\u8f6f\u4ef6\u5f00\u53d1\u7684\u91cd\u8981\u73af\u8282\uff0cPython\u63d0\u4f9b\u4e86\u591a\u79cd\u5de5\u5177\u548c\u65b9\u6cd5\u6765\u5e2e\u52a9\u5f00\u53d1\u8005\u8c03\u8bd5\u548c\u6d4b\u8bd5\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><h4>6.1\u3001\u8c03\u8bd5\u5de5\u5177<\/h4>\n<\/p>\n<ul>\n<li><strong>print()\u51fd\u6570<\/strong>\uff1a\u6700\u7b80\u5355\u7684\u8c03\u8bd5\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5728\u4ee3\u7801\u4e2d\u63d2\u5165<code>print()<\/code>\u8bed\u53e5\u8f93\u51fa\u53d8\u91cf\u7684\u503c\u3002<\/li>\n<li><strong>pdb\u6a21\u5757<\/strong>\uff1aPython\u81ea\u5e26\u7684\u8c03\u8bd5\u5668\uff0c\u652f\u6301\u8bbe\u7f6e\u65ad\u70b9\u3001\u5355\u6b65\u6267\u884c\u7b49\u529f\u80fd\u3002<\/li>\n<li><strong>IDE\u8c03\u8bd5\u529f\u80fd<\/strong>\uff1a\u5927\u591a\u6570IDE\u5982PyCharm\u3001VSCode\u90fd\u63d0\u4f9b\u4e86\u53ef\u89c6\u5316\u7684\u8c03\u8bd5\u5de5\u5177\uff0c\u652f\u6301\u65ad\u70b9\u3001\u53d8\u91cf\u76d1\u89c6\u3001\u8c03\u7528\u5806\u6808\u67e5\u770b\u7b49\u3002<\/li>\n<\/ul>\n<p><h4>6.2\u3001\u6d4b\u8bd5\u6846\u67b6<\/h4>\n<\/p>\n<ul>\n<li><strong>unittest<\/strong>\uff1aPython\u5185\u7f6e\u7684\u5355\u5143\u6d4b\u8bd5\u6846\u67b6\uff0c\u53ef\u4ee5\u7f16\u5199\u6d4b\u8bd5\u7528\u4f8b\u548c\u6d4b\u8bd5\u5957\u4ef6\u3002<\/li>\n<li><strong>pytest<\/strong>\uff1a\u7b2c\u4e09\u65b9\u6d4b\u8bd5\u6846\u67b6\uff0c\u652f\u6301\u7b80\u5355\u6613\u7528\u7684\u6d4b\u8bd5\u8bed\u6cd5\u548c\u4e30\u5bcc\u7684\u63d2\u4ef6\u3002<\/li>\n<li><strong>doctest<\/strong>\uff1a\u7528\u4e8e\u6d4b\u8bd5\u6587\u6863\u5b57\u7b26\u4e32\u4e2d\u7684\u793a\u4f8b\u4ee3\u7801\u3002<\/li>\n<\/ul>\n<p><h3>\u4e03\u3001Python\u9879\u76ee\u7684\u7ec4\u7ec7\u548c\u7ba1\u7406<\/h3>\n<\/p>\n<p><p>\u968f\u7740\u9879\u76ee\u7684\u590d\u6742\u6027\u589e\u52a0\uff0c\u5408\u7406\u7ec4\u7ec7\u548c\u7ba1\u7406Python\u9879\u76ee\u53d8\u5f97\u5c24\u4e3a\u91cd\u8981\u3002<\/p>\n<\/p>\n<p><h4>7.1\u3001\u9879\u76ee\u7ed3\u6784<\/h4>\n<\/p>\n<p><p>\u4e00\u4e2a\u5178\u578b\u7684Python\u9879\u76ee\u7ed3\u6784\u5305\u62ec\u4ee5\u4e0b\u51e0\u4e2a\u90e8\u5206\uff1a<\/p>\n<\/p>\n<p><pre><code>project\/<\/p>\n<p>\u2502<\/p>\n<p>\u251c\u2500\u2500 package\/                # \u5305\u76ee\u5f55<\/p>\n<p>\u2502   \u251c\u2500\u2500 __init__.py         # \u5305\u521d\u59cb\u5316\u6587\u4ef6<\/p>\n<p>\u2502   \u251c\u2500\u2500 module1.py          # \u6a21\u57571<\/p>\n<p>\u2502   \u2514\u2500\u2500 module2.py          # \u6a21\u57572<\/p>\n<p>\u2502<\/p>\n<p>\u251c\u2500\u2500 tests\/                  # \u6d4b\u8bd5\u76ee\u5f55<\/p>\n<p>\u2502   \u251c\u2500\u2500 test_module1.py     # \u6d4b\u8bd5\u6a21\u57571<\/p>\n<p>\u2502   \u2514\u2500\u2500 test_module2.py     # \u6d4b\u8bd5\u6a21\u57572<\/p>\n<p>\u2502<\/p>\n<p>\u251c\u2500\u2500 requirements.txt        # \u4f9d\u8d56\u6587\u4ef6<\/p>\n<p>\u251c\u2500\u2500 setup.py                # \u5b89\u88c5\u914d\u7f6e<\/p>\n<p>\u2514\u2500\u2500 README.md               # \u9879\u76ee\u8bf4\u660e<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>7.2\u3001\u4f9d\u8d56\u7ba1\u7406<\/h4>\n<\/p>\n<ul>\n<li><strong>requirements.txt<\/strong>\uff1a\u5217\u51fa\u9879\u76ee\u4f9d\u8d56\u7684\u6240\u6709Python\u5305\uff0c\u53ef\u4ee5\u4f7f\u7528<code>pip install -r requirements.txt<\/code>\u5b89\u88c5\u3002<\/li>\n<li><strong>pipenv<\/strong>\uff1a\u7528\u4e8e\u521b\u5efa\u865a\u62df\u73af\u5883\u548c\u7ba1\u7406\u4f9d\u8d56\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u9694\u79bb\u4e0d\u540c\u9879\u76ee\u7684\u4f9d\u8d56\u3002<\/li>\n<li><strong>virtualenv<\/strong>\uff1a\u7528\u4e8e\u521b\u5efa\u72ec\u7acb\u7684Python\u73af\u5883\uff0c\u907f\u514d\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u7684\u5305\u51b2\u7a81\u3002<\/li>\n<\/ul>\n<p><h3>\u516b\u3001\u6301\u7eed\u5b66\u4e60\u548c\u5b9e\u8df5<\/h3>\n<\/p>\n<p><p>Python\u662f\u4e00\u95e8\u4e0d\u65ad\u53d1\u5c55\u7684\u8bed\u8a00\uff0c\u4fdd\u6301\u5b66\u4e60\u548c\u5b9e\u8df5\u662f\u63d0\u9ad8\u7f16\u7a0b\u80fd\u529b\u7684\u5173\u952e\u3002<\/p>\n<\/p>\n<p><h4>8.1\u3001\u5b66\u4e60\u8d44\u6e90<\/h4>\n<\/p>\n<ul>\n<li><strong>\u5b98\u65b9\u6587\u6863<\/strong>\uff1aPython\u7684\u5b98\u65b9\u6587\u6863\u662f\u5b66\u4e60\u8bed\u6cd5\u548c\u6807\u51c6\u5e93\u7684\u6700\u4f73\u8d44\u6e90\u3002<\/li>\n<li><strong>\u5728\u7ebf\u8bfe\u7a0b<\/strong>\uff1aCoursera\u3001edX\u3001Udacity\u7b49\u5e73\u53f0\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684Python\u8bfe\u7a0b\u3002<\/li>\n<li><strong>\u7f16\u7a0b\u4e66\u7c4d<\/strong>\uff1a\u5982\u300aPython\u7f16\u7a0b\uff1a\u4ece\u5165\u95e8\u5230\u5b9e\u8df5\u300b\u3001\u300a\u6d41\u7545\u7684Python\u300b\u7b49\u3002<\/li>\n<\/ul>\n<p><h4>8.2\u3001\u5b9e\u8df5\u9879\u76ee<\/h4>\n<\/p>\n<p><p>\u901a\u8fc7\u53c2\u4e0e\u5f00\u6e90\u9879\u76ee\u3001\u5f00\u53d1\u4e2a\u4eba\u9879\u76ee\u6216\u89e3\u51b3\u5b9e\u9645\u95ee\u9898\u6765\u5de9\u56fa\u6240\u5b66\u7684\u77e5\u8bc6\u3002\u53ef\u4ee5\u4ece\u7b80\u5355\u7684\u9879\u76ee\u5f00\u59cb\uff0c\u5982\u7f16\u5199Web\u722c\u866b\u3001\u5f00\u53d1\u5c0f\u578bWeb\u5e94\u7528\u3001\u8fdb\u884c\u6570\u636e\u5206\u6790\u7b49\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\u548c\u5b9e\u8df5\uff0c\u60a8\u5c06\u80fd\u591f\u719f\u7ec3\u638c\u63e1Python\u7f16\u7a0b\uff0c\u5e76\u80fd\u591f\u8fd0\u7528Python\u89e3\u51b3\u5b9e\u9645\u95ee\u9898\u3002\u6301\u7eed\u7684\u5b66\u4e60\u548c\u5b9e\u8df5\u5c06\u5e2e\u52a9\u60a8\u5728Python\u5f00\u53d1\u4e2d\u4e0d\u65ad\u8fdb\u6b65\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5f00\u59cb\u4f7f\u7528Python\u8fdb\u884c\u7f16\u7a0b\uff1f<\/strong><br \/>\u5982\u679c\u60a8\u662fPython\u7f16\u7a0b\u7684\u65b0\u624b\uff0c\u53ef\u4ee5\u4ece\u5b89\u88c5Python\u89e3\u91ca\u5668\u5f00\u59cb\u3002\u8bbf\u95eePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u9002\u5408\u60a8\u64cd\u4f5c\u7cfb\u7edf\u7684\u7248\u672c\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528IDLE\u6216\u5176\u4ed6\u4ee3\u7801\u7f16\u8f91\u5668\uff08\u5982VSCode\u3001PyCharm\u7b49\uff09\u6765\u7f16\u5199\u548c\u8fd0\u884cPython\u4ee3\u7801\u3002\u5efa\u8bae\u4ece\u57fa\u7840\u8bed\u6cd5\u3001\u6570\u636e\u7c7b\u578b\u548c\u63a7\u5236\u7ed3\u6784\u5165\u624b\uff0c\u9010\u6b65\u5b66\u4e60\u51fd\u6570\u3001\u6a21\u5757\u548c\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u7b49\u9ad8\u7ea7\u6982\u5ff5\u3002<\/p>\n<p><strong>Python\u7684\u4e3b\u8981\u5e94\u7528\u9886\u57df\u6709\u54ea\u4e9b\uff1f<\/strong><br \/>Python\u662f\u4e00\u79cd\u591a\u7528\u9014\u7684\u7f16\u7a0b\u8bed\u8a00\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8e\u6570\u636e\u79d1\u5b66\u3001\u673a\u5668\u5b66\u4e60\u3001Web\u5f00\u53d1\u3001\u81ea\u52a8\u5316\u811a\u672c\u548c\u6e38\u620f\u5f00\u53d1\u7b49\u9886\u57df\u3002\u7279\u522b\u662f\u5728\u6570\u636e\u5206\u6790\u548c<a href=\"https:\/\/docs.pingcode.com\/tag\/AI\" target=\"_blank\">\u4eba\u5de5\u667a\u80fd<\/a>\u9886\u57df\uff0cPython\u56e0\u5176\u5f3a\u5927\u7684\u5e93\uff08\u5982Pandas\u3001NumPy\u3001TensorFlow\u7b49\uff09\u800c\u53d7\u5230\u9752\u7750\u3002\u6b64\u5916\uff0cPython\u8fd8\u9002\u7528\u4e8e\u521b\u5efa\u7f51\u7ad9\u540e\u7aef\u548c\u6784\u5efaAPI\uff0c\u6ee1\u8db3\u4e0d\u540c\u9879\u76ee\u7684\u9700\u6c42\u3002<\/p>\n<p><strong>\u5982\u4f55\u63d0\u9ad8\u81ea\u5df1\u7684Python\u7f16\u7a0b\u6280\u80fd\uff1f<\/strong><br \/>\u63d0\u5347Python\u7f16\u7a0b\u6280\u80fd\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u5b9e\u73b0\u3002\u9996\u5148\uff0c\u53c2\u4e0e\u5f00\u6e90\u9879\u76ee\u6216\u8d21\u732e\u4ee3\u7801\uff0c\u53ef\u4ee5\u52a0\u6df1\u5bf9\u771f\u5b9e\u9879\u76ee\u7684\u7406\u89e3\u3002\u5176\u6b21\uff0c\u5728\u7ebf\u5b66\u4e60\u5e73\u53f0\uff08\u5982Coursera\u3001Udacity\u7b49\uff09\u63d0\u4f9b\u4e30\u5bcc\u7684\u8bfe\u7a0b\uff0c\u80fd\u591f\u7cfb\u7edf\u5730\u63d0\u5347\u7f16\u7a0b\u80fd\u529b\u3002\u53c2\u52a0\u7f16\u7a0b\u7ade\u8d5b\u6216\u6311\u6218\uff08\u5982LeetCode\u3001HackerRank\uff09\u4e5f\u80fd\u63d0\u9ad8\u89e3\u9898\u80fd\u529b\u548c\u7b97\u6cd5\u601d\u7ef4\u3002\u6b64\u5916\uff0c\u5b9a\u671f\u9605\u8bfb\u76f8\u5173\u4e66\u7c4d\u548c\u6280\u672f\u535a\u5ba2\uff0c\u4fdd\u6301\u5bf9\u65b0\u6280\u672f\u548c\u8d8b\u52bf\u7684\u5173\u6ce8\uff0c\u6709\u52a9\u4e8e\u4e0d\u65ad\u8fdb\u6b65\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u6309\u7167Python\u8fdb\u884c\u7f16\u7a0b\uff0c\u9700\u8981\u4e86\u89e3Python\u7684\u57fa\u7840\u8bed\u6cd5\u3001\u5b89\u88c5Python\u73af\u5883\u3001\u4f7f\u7528Python\u7f16\u8f91\u5668\u6216ID [&hellip;]","protected":false},"author":3,"featured_media":926508,"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\/926504"}],"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=926504"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/926504\/revisions"}],"predecessor-version":[{"id":926509,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/926504\/revisions\/926509"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/926508"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=926504"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=926504"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=926504"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}