{"id":1030354,"date":"2024-12-31T11:16:32","date_gmt":"2024-12-31T03:16:32","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1030354.html"},"modified":"2024-12-31T11:16:35","modified_gmt":"2024-12-31T03:16:35","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8%e7%94%b5%e8%84%91%e4%b8%8a%e7%94%a8python%e5%86%99%e7%a8%8b%e5%ba%8f","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1030354.html","title":{"rendered":"\u5982\u4f55\u5728\u7535\u8111\u4e0a\u7528python\u5199\u7a0b\u5e8f"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/12\/c0a5d2ee-3ee1-43cc-b7a6-30e898396a5b.webp?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"\u5982\u4f55\u5728\u7535\u8111\u4e0a\u7528python\u5199\u7a0b\u5e8f\" \/><\/p>\n<p><p> <strong>\u5728\u7535\u8111\u4e0a\u7528Python\u5199\u7a0b\u5e8f\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u5b89\u88c5Python\u89e3\u91ca\u5668\u3001\u9009\u62e9\u4e00\u4e2a\u4ee3\u7801\u7f16\u8f91\u5668\u6216IDE\u3001\u719f\u6089Python\u8bed\u6cd5\u3001\u8fd0\u884c\u548c\u8c03\u8bd5\u4ee3\u7801\u3001\u5b66\u4e60\u548c\u4f7f\u7528Python\u5e93\u3002<\/strong> \u5176\u4e2d\uff0c\u9009\u62e9\u4e00\u4e2a\u5408\u9002\u7684\u4ee3\u7801\u7f16\u8f91\u5668\u6216IDE\u975e\u5e38\u91cd\u8981\uff0c\u8fd9\u80fd\u663e\u8457\u63d0\u9ad8\u7f16\u7a0b\u6548\u7387\u548c\u4ee3\u7801\u8d28\u91cf\u3002\u4e0b\u9762\uff0c\u6211\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5728\u7535\u8111\u4e0a\u7528Python\u5199\u7a0b\u5e8f\u7684\u6b65\u9aa4\u548c\u76f8\u5173\u77e5\u8bc6\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u5b89\u88c5Python\u89e3\u91ca\u5668<\/h3>\n<\/p>\n<p><p>\u8981\u5728\u7535\u8111\u4e0a\u5199Python\u7a0b\u5e8f\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5Python\u89e3\u91ca\u5668\u3002Python\u89e3\u91ca\u5668\u662f\u8fd0\u884cPython\u4ee3\u7801\u7684\u5fc5\u5907\u5de5\u5177\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4e0b\u8f7dPython\u89e3\u91ca\u5668<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u8bbf\u95eePython\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/www.python.org\/%EF%BC%89%EF%BC%8C%E4%B8%8B%E8%BD%BD%E9%80%82%E7%94%A8%E4%BA%8E%E4%BD%A0%E7%9A%84%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%EF%BC%88Windows%E3%80%81macOS%E3%80%81Linux%EF%BC%89%E7%9A%84%E6%9C%80%E6%96%B0%E7%89%88%E6%9C%AC%E7%9A%84Python%E5%AE%89%E8%A3%85%E5%8C%85%E3%80%82\">https:\/\/www.python.org\/\uff09\uff0c\u4e0b\u8f7d\u9002\u7528\u4e8e\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\uff08Windows\u3001macOS\u3001Linux\uff09\u7684\u6700\u65b0\u7248\u672c\u7684Python\u5b89\u88c5\u5305\u3002<\/a><\/li>\n<li>\u5bf9\u4e8eWindows\u7528\u6237\uff0c\u4e0b\u8f7d\u7684\u662f\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\uff08.exe\uff09\uff1b\u5bf9\u4e8emacOS\u7528\u6237\uff0c\u4e0b\u8f7d\u7684\u662f\u4e00\u4e2a.pkg\u6587\u4ef6\uff1b\u5bf9\u4e8eLinux\u7528\u6237\uff0c\u53ef\u4ee5\u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177\u5b89\u88c5\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5Python\u89e3\u91ca\u5668<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u8fd0\u884c\u4e0b\u8f7d\u7684\u5b89\u88c5\u5305\uff0c\u6309\u7167\u63d0\u793a\u8fdb\u884c\u5b89\u88c5\u3002<\/li>\n<li>\u5b89\u88c5\u65f6\uff0c\u786e\u4fdd\u52fe\u9009\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u8fd9\u6837\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u76f4\u63a5\u4f7f\u7528Python\u547d\u4ee4\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u6253\u5f00\u547d\u4ee4\u884c\u7a97\u53e3\uff08Windows\u7528\u6237\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u63d0\u793a\u7b26cmd\u6216PowerShell\uff0cmacOS\u548cLinux\u7528\u6237\u53ef\u4ee5\u4f7f\u7528\u7ec8\u7aef\uff09\u3002<\/li>\n<li>\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\uff0c\u67e5\u770b\u662f\u5426\u6b63\u786e\u663e\u793aPython\u7248\u672c\u53f7\u3002\u5982\u679c\u663e\u793a\u6b63\u786e\u7248\u672c\u53f7\uff0c\u8bf4\u660ePython\u5b89\u88c5\u6210\u529f\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u4e8c\u3001\u9009\u62e9\u4e00\u4e2a\u4ee3\u7801\u7f16\u8f91\u5668\u6216IDE<\/h3>\n<\/p>\n<p><p>\u4ee3\u7801\u7f16\u8f91\u5668\u6216\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u662f\u7f16\u5199\u548c\u8c03\u8bd5Python\u4ee3\u7801\u7684\u91cd\u8981\u5de5\u5177\u3002\u9009\u62e9\u4e00\u4e2a\u5408\u9002\u7684\u7f16\u8f91\u5668\u6216IDE\uff0c\u53ef\u4ee5\u6781\u5927\u63d0\u9ad8\u7f16\u7a0b\u6548\u7387\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4ee3\u7801\u7f16\u8f91\u5668<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>Visual Studio Code<\/strong>\uff08VS Code\uff09\uff1a\u4e00\u6b3e\u8f7b\u91cf\u7ea7\u4f46\u529f\u80fd\u5f3a\u5927\u7684\u4ee3\u7801\u7f16\u8f91\u5668\uff0c\u652f\u6301\u591a\u79cd\u7f16\u7a0b\u8bed\u8a00\uff0c\u5305\u62ecPython\u3002\u5b83\u6709\u4e30\u5bcc\u7684\u63d2\u4ef6\u751f\u6001\u7cfb\u7edf\uff0c\u53ef\u4ee5\u5b89\u88c5Python\u63d2\u4ef6\u6765\u63d0\u4f9b\u4ee3\u7801\u8865\u5168\u3001\u8c03\u8bd5\u7b49\u529f\u80fd\u3002<\/li>\n<li><strong>Sublime Text<\/strong>\uff1a\u4e00\u6b3e\u5feb\u901f\u3001\u7b80\u6d01\u7684\u4ee3\u7801\u7f16\u8f91\u5668\uff0c\u652f\u6301\u591a\u79cd\u7f16\u7a0b\u8bed\u8a00\u3002\u901a\u8fc7\u5b89\u88c5Python\u63d2\u4ef6\uff0c\u53ef\u4ee5\u83b7\u5f97\u66f4\u597d\u7684Python\u7f16\u7a0b\u4f53\u9a8c\u3002<\/li>\n<li><strong>Atom<\/strong>\uff1a\u7531GitHub\u5f00\u53d1\u7684\u5f00\u6e90\u4ee3\u7801\u7f16\u8f91\u5668\uff0c\u652f\u6301\u591a\u79cd\u7f16\u7a0b\u8bed\u8a00\u3002\u901a\u8fc7\u5b89\u88c5Python\u63d2\u4ef6\uff0c\u53ef\u4ee5\u63d0\u4f9b\u4ee3\u7801\u8865\u5168\u3001\u8bed\u6cd5\u9ad8\u4eae\u7b49\u529f\u80fd\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>PyCharm<\/strong>\uff1a\u4e00\u6b3e\u4e13\u4e1a\u7684Python IDE\uff0c\u63d0\u4f9b\u4e30\u5bcc\u7684\u529f\u80fd\uff0c\u5305\u62ec\u4ee3\u7801\u8865\u5168\u3001\u8c03\u8bd5\u3001\u6d4b\u8bd5\u3001\u7248\u672c\u63a7\u5236\u7b49\u3002\u9002\u5408\u9700\u8981\u8fdb\u884c\u590d\u6742\u9879\u76ee\u5f00\u53d1\u7684\u7528\u6237\u3002<\/li>\n<li><strong>Spyder<\/strong>\uff1a\u4e13\u4e3a\u79d1\u5b66\u8ba1\u7b97\u548c\u6570\u636e\u5206\u6790\u8bbe\u8ba1\u7684Python IDE\uff0c\u96c6\u6210\u4e86\u8bb8\u591a\u6570\u636e\u79d1\u5b66\u5de5\u5177\u548c\u5e93\uff0c\u9002\u5408\u6570\u636e\u79d1\u5b66\u5bb6\u548c\u7814\u7a76\u4eba\u5458\u4f7f\u7528\u3002<\/li>\n<li><strong>Jupyter Notebook<\/strong>\uff1a\u4e00\u79cd\u4ea4\u4e92\u5f0f\u7b14\u8bb0\u672c\u73af\u5883\uff0c\u652f\u6301\u4ee3\u7801\u3001\u6587\u672c\u3001\u6570\u5b66\u516c\u5f0f\u3001\u56fe\u8868\u7b49\uff0c\u5e7f\u6cdb\u7528\u4e8e\u6570\u636e\u79d1\u5b66\u3001<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u548c\u6559\u80b2\u9886\u57df\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u4e09\u3001\u719f\u6089Python\u8bed\u6cd5<\/h3>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u7f16\u5199Python\u7a0b\u5e8f\u4e4b\u524d\uff0c\u719f\u6089Python\u7684\u57fa\u672c\u8bed\u6cd5\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9bPython\u7f16\u7a0b\u7684\u57fa\u672c\u6982\u5ff5\u548c\u8bed\u6cd5\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u53d8\u91cf\u548c\u6570\u636e\u7c7b\u578b<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u53d8\u91cf<\/strong>\uff1a\u7528\u4e8e\u5b58\u50a8\u6570\u636e\u7684\u547d\u540d\u7a7a\u95f4\u3002Python\u662f\u52a8\u6001\u7c7b\u578b\u8bed\u8a00\uff0c\u53d8\u91cf\u4e0d\u9700\u8981\u663e\u5f0f\u58f0\u660e\u7c7b\u578b\u3002\n<pre><code class=\"language-python\">x = 10<\/p>\n<p>y = 3.14<\/p>\n<p>name = &quot;John&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li><strong>\u6570\u636e\u7c7b\u578b<\/strong>\uff1aPython\u652f\u6301\u591a\u79cd\u6570\u636e\u7c7b\u578b\uff0c\u5305\u62ec\u6574\u6570\uff08int\uff09\u3001\u6d6e\u70b9\u6570\uff08float\uff09\u3001\u5b57\u7b26\u4e32\uff08str\uff09\u3001\u5e03\u5c14\u503c\uff08bool\uff09\u7b49\u3002\n<pre><code class=\"language-python\">a = 5       # int<\/p>\n<p>b = 2.5     # float<\/p>\n<p>c = &quot;Hello&quot; # str<\/p>\n<p>d = True    # bool<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u8fd0\u7b97\u7b26<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u7b97\u672f\u8fd0\u7b97\u7b26\uff1a<code>+<\/code>, <code>-<\/code>, <code>*<\/code>, <code>\/<\/code>, <code>\/\/<\/code>, <code>%<\/code>, <code><\/code>\n<pre><code class=\"language-python\">a = 10<\/p>\n<p>b = 3<\/p>\n<p>print(a + b)  # 13<\/p>\n<p>print(a - b)  # 7<\/p>\n<p>print(a * b)  # 30<\/p>\n<p>print(a \/ b)  # 3.3333333333333335<\/p>\n<p>print(a \/\/ b) # 3<\/p>\n<p>print(a % b)  # 1<\/p>\n<p>print(a  b) # 1000<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u6bd4\u8f83\u8fd0\u7b97\u7b26\uff1a<code>==<\/code>, <code>!=<\/code>, <code>&gt;<\/code>, <code>&lt;<\/code>, <code>&gt;=<\/code>, <code>&lt;=<\/code>\n<pre><code class=\"language-python\">a = 10<\/p>\n<p>b = 3<\/p>\n<p>print(a == b) # False<\/p>\n<p>print(a != b) # True<\/p>\n<p>print(a &gt; b)  # True<\/p>\n<p>print(a &lt; b)  # False<\/p>\n<p>print(a &gt;= b) # True<\/p>\n<p>print(a &lt;= b) # False<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u63a7\u5236\u7ed3\u6784<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u6761\u4ef6\u8bed\u53e5<\/strong>\uff1a\n<pre><code class=\"language-python\">x = 10<\/p>\n<p>if x &gt; 5:<\/p>\n<p>    print(&quot;x is greater than 5&quot;)<\/p>\n<p>elif x == 5:<\/p>\n<p>    print(&quot;x is equal to 5&quot;)<\/p>\n<p>else:<\/p>\n<p>    print(&quot;x is less than 5&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li><strong>\u5faa\u73af\u8bed\u53e5<\/strong>\uff1a\n<pre><code class=\"language-python\"># for\u5faa\u73af<\/p>\n<p>for i in range(5):<\/p>\n<p>    print(i)<\/p>\n<h2><strong>while\u5faa\u73af<\/strong><\/h2>\n<p>i = 0<\/p>\n<p>while i &lt; 5:<\/p>\n<p>    print(i)<\/p>\n<p>    i += 1<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u51fd\u6570<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u51fd\u6570\u662f\u53ef\u91cd\u7528\u7684\u4ee3\u7801\u5757\uff0c\u7528\u4e8e\u6267\u884c\u7279\u5b9a\u4efb\u52a1\u3002\u4f7f\u7528<code>def<\/code>\u5173\u952e\u5b57\u5b9a\u4e49\u51fd\u6570\u3002\n<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;))  # Hello, Alice!<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u7c7b\u548c\u5bf9\u8c61<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u7c7b\u662f\u521b\u5efa\u5bf9\u8c61\u7684\u84dd\u56fe\uff0c\u4f7f\u7528<code>class<\/code>\u5173\u952e\u5b57\u5b9a\u4e49\u7c7b\u3002\n<pre><code class=\"language-python\">class Dog:<\/p>\n<p>    def __init__(self, name, age):<\/p>\n<p>        self.name = name<\/p>\n<p>        self.age = age<\/p>\n<p>    def bark(self):<\/p>\n<p>        return &quot;Woof!&quot;<\/p>\n<p>my_dog = Dog(&quot;Buddy&quot;, 3)<\/p>\n<p>print(my_dog.name)  # Buddy<\/p>\n<p>print(my_dog.bark()) # Woof!<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u56db\u3001\u8fd0\u884c\u548c\u8c03\u8bd5\u4ee3\u7801<\/h3>\n<\/p>\n<p><p>\u7f16\u5199\u5b8cPython\u4ee3\u7801\u540e\uff0c\u9700\u8981\u8fd0\u884c\u548c\u8c03\u8bd5\u4ee3\u7801\uff0c\u4ee5\u786e\u4fdd\u4ee3\u7801\u7684\u6b63\u786e\u6027\u548c\u529f\u80fd\u7684\u5b9e\u73b0\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u8fd0\u884cPython\u4ee3\u7801<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u5728\u547d\u4ee4\u884c\u4e2d\u4f7f\u7528<code>python<\/code>\u547d\u4ee4\u8fd0\u884cPython\u811a\u672c\u3002\u4f8b\u5982\uff0c\u6709\u4e00\u4e2a\u540d\u4e3a<code>script.py<\/code>\u7684Python\u6587\u4ef6\uff0c\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165<code>python script.py<\/code>\u8fd0\u884c\u8be5\u811a\u672c\u3002<\/li>\n<li>\u5728\u4ee3\u7801\u7f16\u8f91\u5668\u6216IDE\u4e2d\uff0c\u901a\u5e38\u63d0\u4f9b\u4e86\u76f4\u63a5\u8fd0\u884c\u4ee3\u7801\u7684\u6309\u94ae\u6216\u5feb\u6377\u952e\u3002\u4f8b\u5982\uff0c\u5728VS Code\u4e2d\uff0c\u53ef\u4ee5\u70b9\u51fb\u53f3\u4e0a\u89d2\u7684\u8fd0\u884c\u6309\u94ae\uff0c\u6216\u4f7f\u7528\u5feb\u6377\u952e<code>Ctrl+F5<\/code>\u8fd0\u884c\u4ee3\u7801\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u8c03\u8bd5Python\u4ee3\u7801<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u4f7f\u7528print\u8bed\u53e5\u8c03\u8bd5<\/strong>\uff1a\u5728\u4ee3\u7801\u4e2d\u63d2\u5165<code>print<\/code>\u8bed\u53e5\uff0c\u8f93\u51fa\u53d8\u91cf\u7684\u503c\u6216\u7a0b\u5e8f\u7684\u6267\u884c\u8def\u5f84\uff0c\u5e2e\u52a9\u67e5\u627e\u95ee\u9898\u3002\n<pre><code class=\"language-python\">def add(a, b):<\/p>\n<p>    print(f&quot;a: {a}, b: {b}&quot;)  # \u8c03\u8bd5\u8f93\u51fa<\/p>\n<p>    return a + b<\/p>\n<p>result = add(5, 3)<\/p>\n<p>print(f&quot;Result: {result}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li><strong>\u4f7f\u7528\u8c03\u8bd5\u5de5\u5177<\/strong>\uff1a\u73b0\u4ee3\u7684\u4ee3\u7801\u7f16\u8f91\u5668\u548cIDE\u901a\u5e38\u96c6\u6210\u4e86\u8c03\u8bd5\u5de5\u5177\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u65ad\u70b9\u3001\u5355\u6b65\u6267\u884c\u3001\u67e5\u770b\u53d8\u91cf\u503c\u7b49\u3002\u4f8b\u5982\uff0c\u5728VS Code\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u70b9\u51fb\u884c\u53f7\u5de6\u4fa7\u7684\u7a7a\u767d\u533a\u57df\u8bbe\u7f6e\u65ad\u70b9\uff0c\u7136\u540e\u70b9\u51fb\u8fd0\u884c\u6309\u94ae\u65c1\u8fb9\u7684\u8c03\u8bd5\u6309\u94ae\uff0c\u8fdb\u5165\u8c03\u8bd5\u6a21\u5f0f\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u4e94\u3001\u5b66\u4e60\u548c\u4f7f\u7528Python\u5e93<\/h3>\n<\/p>\n<p><p>Python\u62e5\u6709\u4e30\u5bcc\u7684\u6807\u51c6\u5e93\u548c\u7b2c\u4e09\u65b9\u5e93\uff0c\u53ef\u4ee5\u6781\u5927\u5730\u6269\u5c55Python\u7684\u529f\u80fd\uff0c\u6ee1\u8db3\u5404\u79cd\u7f16\u7a0b\u9700\u6c42\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6807\u51c6\u5e93<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>Python\u6807\u51c6\u5e93\u5305\u542b\u4e86\u8bb8\u591a\u5e38\u7528\u7684\u6a21\u5757\u548c\u5305\uff0c\u53ef\u4ee5\u76f4\u63a5\u5bfc\u5165\u4f7f\u7528\u3002\u4f8b\u5982\uff0c<code>math<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u6570\u5b66\u51fd\u6570\uff0c<code>datetime<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u65e5\u671f\u548c\u65f6\u95f4\u5904\u7406\u529f\u80fd\u3002\n<pre><code class=\"language-python\">import math<\/p>\n<p>import datetime<\/p>\n<p>print(math.sqrt(16))  # 4.0<\/p>\n<p>print(datetime.datetime.now())  # \u5f53\u524d\u65e5\u671f\u548c\u65f6\u95f4<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u7b2c\u4e09\u65b9\u5e93<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u901a\u8fc7Python\u5305\u7ba1\u7406\u5668<code>pip<\/code>\u53ef\u4ee5\u5b89\u88c5\u548c\u4f7f\u7528\u7b2c\u4e09\u65b9\u5e93\u3002\u5e38\u89c1\u7684\u7b2c\u4e09\u65b9\u5e93\u5305\u62ec<code>numpy<\/code>\uff08\u6570\u503c\u8ba1\u7b97\uff09\u3001<code>pandas<\/code>\uff08\u6570\u636e\u5206\u6790\uff09\u3001<code>matplotlib<\/code>\uff08\u6570\u636e\u53ef\u89c6\u5316\uff09\u3001<code>requests<\/code>\uff08HTTP\u8bf7\u6c42\uff09\u7b49\u3002\n<pre><code class=\"language-python\"># \u5b89\u88c5\u7b2c\u4e09\u65b9\u5e93<\/p>\n<h2><strong>pip install numpy pandas matplotlib requests<\/strong><\/h2>\n<p>import numpy as np<\/p>\n<p>import pandas as pd<\/p>\n<p>import matplotlib.pyplot as plt<\/p>\n<p>import requests<\/p>\n<h2><strong>\u4f7f\u7528numpy\u8fdb\u884c\u6570\u7ec4\u8ba1\u7b97<\/strong><\/h2>\n<p>arr = np.array([1, 2, 3, 4])<\/p>\n<p>print(arr * 2)  # [2 4 6 8]<\/p>\n<h2><strong>\u4f7f\u7528pandas\u8fdb\u884c\u6570\u636e\u5206\u6790<\/strong><\/h2>\n<p>data = {&#39;Name&#39;: [&#39;Alice&#39;, &#39;Bob&#39;, &#39;Charlie&#39;], &#39;Age&#39;: [25, 30, 35]}<\/p>\n<p>df = pd.DataFrame(data)<\/p>\n<p>print(df)<\/p>\n<h2><strong>\u4f7f\u7528matplotlib\u8fdb\u884c\u6570\u636e\u53ef\u89c6\u5316<\/strong><\/h2>\n<p>plt.plot([1, 2, 3], [4, 5, 6])<\/p>\n<p>plt.show()<\/p>\n<h2><strong>\u4f7f\u7528requests\u8fdb\u884cHTTP\u8bf7\u6c42<\/strong><\/h2>\n<p>response = requests.get(&#39;https:\/\/api.github.com&#39;)<\/p>\n<p>print(response.json())<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u516d\u3001\u5b9e\u8df5\u548c\u9879\u76ee<\/h3>\n<\/p>\n<p><p>\u5b66\u4e60\u7f16\u7a0b\u8bed\u8a00\u6700\u91cd\u8981\u7684\u662f\u5b9e\u8df5\u3002\u901a\u8fc7\u5b9e\u9645\u9879\u76ee\u548c\u7ec3\u4e60\uff0c\u53ef\u4ee5\u66f4\u597d\u5730\u638c\u63e1Python\u7f16\u7a0b\u6280\u80fd\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u7ec3\u4e60\u9898\u548c\u7f16\u7a0b\u6311\u6218<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u53ef\u4ee5\u5728LeetCode\u3001HackerRank\u3001Codewars\u7b49\u7f16\u7a0b\u6311\u6218\u5e73\u53f0\u4e0a\u7ec3\u4e60Python\u7f16\u7a0b\u9898\u76ee\uff0c\u63d0\u9ad8\u7f16\u7a0b\u6280\u80fd\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u4e2a\u4eba\u9879\u76ee<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u6839\u636e\u81ea\u5df1\u7684\u5174\u8da3\u548c\u9700\u6c42\uff0c\u9009\u62e9\u4e00\u4e2a\u5b9e\u9645\u9879\u76ee\u8fdb\u884c\u5f00\u53d1\u3002\u4f8b\u5982\uff0c\u5f00\u53d1\u4e00\u4e2a\u7b80\u5355\u7684\u7f51\u9875\u722c\u866b\u3001\u6570\u636e\u5206\u6790\u5de5\u5177\u3001\u5c0f\u6e38\u620f\u7b49\u3002\u901a\u8fc7\u5b9e\u9645\u9879\u76ee\uff0c\u53ef\u4ee5\u6df1\u5165\u7406\u89e3Python\u7f16\u7a0b\u7684\u5404\u4e2a\u65b9\u9762\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5f00\u6e90\u9879\u76ee\u8d21\u732e<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u53c2\u4e0e\u5f00\u6e90\u9879\u76ee\u662f\u63d0\u9ad8\u7f16\u7a0b\u6280\u80fd\u548c\u83b7\u5f97\u5b9e\u9645\u7ecf\u9a8c\u7684\u597d\u65b9\u6cd5\u3002\u5728GitHub\u4e0a\u5bfb\u627e\u611f\u5174\u8da3\u7684\u5f00\u6e90\u9879\u76ee\uff0c\u9605\u8bfb\u4ee3\u7801\u3001\u63d0\u4ea4\u8d21\u732e\u3001\u53c2\u4e0e\u8ba8\u8bba\uff0c\u53ef\u4ee5\u5b66\u5230\u5f88\u591a\u5b9e\u7528\u7684\u7f16\u7a0b\u77e5\u8bc6\u548c\u6280\u5de7\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u4e03\u3001\u6301\u7eed\u5b66\u4e60\u548c\u793e\u533a\u4ea4\u6d41<\/h3>\n<\/p>\n<p><p>\u7f16\u7a0b\u662f\u4e00\u95e8\u4e0d\u65ad\u5b66\u4e60\u548c\u8fdb\u6b65\u7684\u6280\u80fd\u3002\u901a\u8fc7\u6301\u7eed\u5b66\u4e60\u548c\u793e\u533a\u4ea4\u6d41\uff0c\u53ef\u4ee5\u4fdd\u6301\u5bf9Python\u7f16\u7a0b\u7684\u70ed\u60c5\u548c\u5174\u8da3\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b66\u4e60\u8d44\u6e90<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u4e66\u7c4d<\/strong>\uff1a\u9605\u8bfbPython\u76f8\u5173\u7684\u4e66\u7c4d\uff0c\u5982\u300aPython\u7f16\u7a0b\uff1a\u4ece\u5165\u95e8\u5230\u5b9e\u8df5\u300b\u3001\u300a\u6d41\u7545\u7684Python\u300b\u3001\u300aPython\u6570\u636e\u79d1\u5b66\u624b\u518c\u300b\u7b49\u3002<\/li>\n<li><strong>\u5728\u7ebf\u8bfe\u7a0b<\/strong>\uff1a\u53c2\u52a0\u5728\u7ebf\u5b66\u4e60\u5e73\u53f0\u4e0a\u7684Python\u8bfe\u7a0b\uff0c\u5982Coursera\u3001edX\u3001Udacity\u7b49\u3002<\/li>\n<li><strong>\u535a\u5ba2\u548c\u6587\u7ae0<\/strong>\uff1a\u5173\u6ce8Python\u76f8\u5173\u7684\u6280\u672f\u535a\u5ba2\u548c\u6587\u7ae0\uff0c\u4e86\u89e3\u6700\u65b0\u7684\u6280\u672f\u548c\u5b9e\u8df5\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u793e\u533a\u4ea4\u6d41<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u8bba\u575b\u548c\u8ba8\u8bba\u533a<\/strong>\uff1a\u5728Stack Overflow\u3001Reddit\u3001Python.org\u7b49\u8bba\u575b\u548c\u8ba8\u8bba\u533a\u63d0\u95ee\u548c\u56de\u7b54\u95ee\u9898\uff0c\u4e0e\u5176\u4ed6\u7f16\u7a0b\u7231\u597d\u8005\u4ea4\u6d41\u3002<\/li>\n<li><strong>\u793e\u4ea4\u5a92\u4f53<\/strong>\uff1a\u5728Twitter\u3001LinkedIn\u7b49\u793e\u4ea4\u5a92\u4f53\u5e73\u53f0\u4e0a\u5173\u6ce8Python\u76f8\u5173\u7684\u8d26\u53f7\u548c\u8bdd\u9898\uff0c\u83b7\u53d6\u6700\u65b0\u7684\u4fe1\u606f\u548c\u52a8\u6001\u3002<\/li>\n<li><strong>\u672c\u5730\u7528\u6237\u7ec4\u548c\u4f1a\u8bae<\/strong>\uff1a\u53c2\u52a0\u672c\u5730\u7684Python\u7528\u6237\u7ec4\u6d3b\u52a8\u548c\u6280\u672f\u4f1a\u8bae\uff0c\u4e0e\u5176\u4ed6\u7f16\u7a0b\u7231\u597d\u8005\u9762\u5bf9\u9762\u4ea4\u6d41\uff0c\u5206\u4eab\u7ecf\u9a8c\u548c\u89c1\u89e3\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u53ef\u4ee5\u5728\u7535\u8111\u4e0a\u7528Python\u5199\u7a0b\u5e8f\uff0c\u4ece\u5165\u95e8\u5230\u7cbe\u901a\uff0c\u9010\u6b65\u63d0\u9ad8\u7f16\u7a0b\u6280\u80fd\u548c\u9879\u76ee\u5f00\u53d1\u80fd\u529b\u3002\u5e0c\u671b\u8fd9\u7bc7\u6587\u7ae0\u80fd\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u7406\u89e3\u548c\u638c\u63e1Python\u7f16\u7a0b\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5f00\u59cb\u5728\u7535\u8111\u4e0a\u5b89\u88c5Python\u4ee5\u7f16\u5199\u7a0b\u5e8f\uff1f<\/strong><br \/>\u8981\u5728\u7535\u8111\u4e0a\u7f16\u5199Python\u7a0b\u5e8f\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\uff0c\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u786e\u4fdd\u9009\u62e9\u5c06Python\u6dfb\u52a0\u5230\u7cfb\u7edf\u8def\u5f84\u7684\u9009\u9879\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u8f93\u5165<code>python<\/code>\u6216<code>python3<\/code>\u6765\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\u3002<\/p>\n<p><strong>\u5728\u7f16\u5199Python\u7a0b\u5e8f\u65f6\uff0c\u63a8\u8350\u4f7f\u7528\u54ea\u4e9b\u5f00\u53d1\u73af\u5883\uff1f<\/strong><br \/>\u6709\u591a\u79cd\u5f00\u53d1\u73af\u5883\u53ef\u4ee5\u9009\u62e9\uff0c\u5e38\u89c1\u7684\u6709PyCharm\u3001VS Code\u3001Jupyter Notebook\u548cIDLE\u3002PyCharm\u63d0\u4f9b\u5f3a\u5927\u7684\u529f\u80fd\u548c\u8c03\u8bd5\u5de5\u5177\uff0cVS Code\u5219\u4ee5\u5176\u8f7b\u4fbf\u548c\u6269\u5c55\u6027\u53d7\u5230\u6b22\u8fce\uff0cJupyter Notebook\u9002\u5408\u6570\u636e\u79d1\u5b66\u548c\u53ef\u89c6\u5316\u5de5\u4f5c\uff0cIDLE\u662fPython\u81ea\u5e26\u7684\u7b80\u5355\u7f16\u8f91\u5668\uff0c\u9002\u5408\u521d\u5b66\u8005\u3002<\/p>\n<p><strong>\u5982\u4f55\u8c03\u8bd5\u6211\u7684Python\u7a0b\u5e8f\u4ee5\u89e3\u51b3\u9519\u8bef\uff1f<\/strong><br \/>\u8c03\u8bd5Python\u7a0b\u5e8f\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u5185\u7f6e\u7684\u8c03\u8bd5\u5de5\u5177\u6216\u6253\u5370\u8bed\u53e5\u6765\u5b9e\u73b0\u3002\u8bb8\u591a\u5f00\u53d1\u73af\u5883\uff0c\u5982PyCharm\u548cVS Code\uff0c\u63d0\u4f9b\u4e86\u56fe\u5f62\u5316\u7684\u8c03\u8bd5\u5de5\u5177\uff0c\u53ef\u4ee5\u9010\u884c\u6267\u884c\u4ee3\u7801\uff0c\u89c2\u5bdf\u53d8\u91cf\u7684\u503c\u3002\u6b64\u5916\uff0c\u4f7f\u7528<code>print()<\/code>\u8bed\u53e5\u5728\u5173\u952e\u4f4d\u7f6e\u8f93\u51fa\u53d8\u91cf\u7684\u72b6\u6001\u4e5f\u662f\u4e00\u79cd\u7b80\u5355\u6709\u6548\u7684\u8c03\u8bd5\u65b9\u6cd5\u3002\u8fd8\u53ef\u4ee5\u8003\u8651\u5b66\u4e60\u4f7f\u7528Python\u7684<code>pdb<\/code>\u6a21\u5757\uff0c\u5b83\u63d0\u4f9b\u66f4\u4e3a\u4e13\u4e1a\u7684\u8c03\u8bd5\u529f\u80fd\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728\u7535\u8111\u4e0a\u7528Python\u5199\u7a0b\u5e8f\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u5b89\u88c5Python\u89e3\u91ca\u5668\u3001\u9009\u62e9\u4e00\u4e2a\u4ee3\u7801\u7f16\u8f91\u5668\u6216IDE\u3001\u719f\u6089Python\u8bed [&hellip;]","protected":false},"author":3,"featured_media":1030366,"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\/1030354"}],"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=1030354"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1030354\/revisions"}],"predecessor-version":[{"id":1030369,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1030354\/revisions\/1030369"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1030366"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1030354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1030354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1030354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}