{"id":1166753,"date":"2025-01-15T15:35:52","date_gmt":"2025-01-15T07:35:52","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1166753.html"},"modified":"2025-01-15T15:35:55","modified_gmt":"2025-01-15T07:35:55","slug":"pycharm%e5%a6%82%e4%bd%95%e7%94%a8python%e7%9a%84%e5%ba%93","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1166753.html","title":{"rendered":"pycharm\u5982\u4f55\u7528python\u7684\u5e93"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25210800\/937678a1-b076-482f-9661-e21398fca1ca.webp\" alt=\"pycharm\u5982\u4f55\u7528python\u7684\u5e93\" \/><\/p>\n<p><p> <strong>Pycharm\u4f7f\u7528Python\u5e93\u7684\u65b9\u6cd5\u6709\uff1a\u5b89\u88c5\u5e93\u3001\u5bfc\u5165\u5e93\u3001\u4f7f\u7528\u5e93\u3001\u8c03\u8bd5\u4ee3\u7801<\/strong>\u3002\u4e0b\u9762\u6211\u5c06\u8be6\u7ec6\u63cf\u8ff0\u5982\u4f55\u5728Pycharm\u4e2d\u4f7f\u7528Python\u7684\u5e93\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u5b89\u88c5\u5e93<\/p>\n<\/p>\n<p><p>\u4f7f\u7528Python\u5e93\u7684\u7b2c\u4e00\u6b65\u662f\u786e\u4fdd\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86\u8fd9\u4e9b\u5e93\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7Pycharm\u7684\u5185\u7f6e\u529f\u80fd\u6765\u5b9e\u73b0\u8fd9\u4e00\u70b9\u3002\u9996\u5148\uff0c\u6253\u5f00\u4f60\u7684Pycharm\u9879\u76ee\uff0c\u7136\u540e\u70b9\u51fb\u201cFile\u201d -&gt; \u201cSettings\u201d -&gt; \u201cProject: <your_project_name>\u201d -&gt; \u201cPython Interpreter\u201d\u3002\u5728\u8fd9\u4e2a\u754c\u9762\u4e2d\uff0c\u4f60\u53ef\u4ee5\u770b\u5230\u5df2\u7ecf\u5b89\u88c5\u7684\u6240\u6709\u5e93\u3002\u70b9\u51fb\u53f3\u4fa7\u7684\u201c+\u201d\u6309\u94ae\uff0c\u8f93\u5165\u4f60\u60f3\u5b89\u88c5\u7684\u5e93\u7684\u540d\u5b57\uff0c\u7136\u540e\u70b9\u51fb\u201cInstall Package\u201d\u6309\u94ae\u3002\u8fd9\u6837\uff0cPycharm\u4f1a\u81ea\u52a8\u4e0b\u8f7d\u5e76\u5b89\u88c5\u4f60\u6240\u9700\u8981\u7684\u5e93\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u5bfc\u5165\u5e93<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u597d\u5e93\u4e4b\u540e\uff0c\u4f60\u9700\u8981\u5728\u4f60\u7684Python\u4ee3\u7801\u6587\u4ef6\u4e2d\u5bfc\u5165\u8fd9\u4e9b\u5e93\u3002\u5bfc\u5165\u5e93\u7684\u65b9\u5f0f\u5f88\u7b80\u5355\uff0c\u53ea\u9700\u8981\u5728\u4f60\u7684Python\u6587\u4ef6\u7684\u5f00\u5934\u4f7f\u7528<code>import<\/code>\u8bed\u53e5\u5373\u53ef\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4f60\u60f3\u4f7f\u7528<code>numpy<\/code>\u5e93\uff0c\u4f60\u53ea\u9700\u8981\u5728\u4ee3\u7801\u5f00\u5934\u5199\u4e0a<code>import numpy as np<\/code>\u3002\u8fd9\u6837\uff0c\u4f60\u5c31\u53ef\u4ee5\u5728\u4ee3\u7801\u4e2d\u4f7f\u7528<code>np<\/code>\u6765\u4ee3\u8868<code>numpy<\/code>\u5e93\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001\u4f7f\u7528\u5e93<\/p>\n<\/p>\n<p><p>\u5bfc\u5165\u5e93\u4e4b\u540e\uff0c\u4f60\u5c31\u53ef\u4ee5\u5728\u4ee3\u7801\u4e2d\u4f7f\u7528\u8fd9\u4e9b\u5e93\u63d0\u4f9b\u7684\u529f\u80fd\u4e86\u3002\u4f8b\u5982\uff0c\u5047\u8bbe\u4f60\u5df2\u7ecf\u5b89\u88c5\u5e76\u5bfc\u5165\u4e86<code>numpy<\/code>\u5e93\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u5b83\u6765\u8fdb\u884c\u5404\u79cd\u6570\u5b66\u8ba1\u7b97\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u4e00\u7ef4\u6570\u7ec4<\/strong><\/h2>\n<p>arr = np.array([1, 2, 3, 4, 5])<\/p>\n<p>print(arr)<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4<\/strong><\/h2>\n<p>arr_2d = np.array([[1, 2, 3], [4, 5, 6]])<\/p>\n<p>print(arr_2d)<\/p>\n<h2><strong>\u4f7f\u7528numpy\u8fdb\u884c\u6570\u5b66\u8fd0\u7b97<\/strong><\/h2>\n<p>sum_arr = np.sum(arr)<\/p>\n<p>print(f&quot;Sum of array: {sum_arr}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u56db\u3001\u8c03\u8bd5\u4ee3\u7801<\/p>\n<\/p>\n<p><p>\u5728Pycharm\u4e2d\u8c03\u8bd5\u4ee3\u7801\u4e5f\u662f\u975e\u5e38\u65b9\u4fbf\u7684\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u65ad\u70b9\u3001\u89c2\u5bdf\u53d8\u91cf\u503c\u4ee5\u53ca\u5355\u6b65\u6267\u884c\u7b49\u529f\u80fd\u6765\u8c03\u8bd5\u4f60\u7684\u4ee3\u7801\u3002\u9996\u5148\uff0c\u4f60\u9700\u8981\u5728\u4f60\u7684\u4ee3\u7801\u4e2d\u8bbe\u7f6e\u65ad\u70b9\u3002\u4f60\u53ef\u4ee5\u5728\u4ee3\u7801\u884c\u53f7\u7684\u5de6\u4fa7\u70b9\u51fb\uff0c\u8bbe\u7f6e\u4e00\u4e2a\u7ea2\u8272\u7684\u65ad\u70b9\u3002\u7136\u540e\uff0c\u70b9\u51fbPycharm\u5de5\u5177\u680f\u4e2d\u7684\u201cDebug\u201d\u6309\u94ae\uff0c\u6216\u8005\u6309Shift + F9\u5f00\u59cb\u8c03\u8bd5\u3002\u8c03\u8bd5\u8fc7\u7a0b\u4e2d\uff0c\u4f60\u53ef\u4ee5\u770b\u5230\u5f53\u524d\u6267\u884c\u7684\u4ee3\u7801\u884c\uff0c\u67e5\u770b\u53d8\u91cf\u7684\u503c\uff0c\u5e76\u4e14\u53ef\u4ee5\u5355\u6b65\u6267\u884c\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><h3>\u8be6\u7ec6\u63cf\u8ff0\u5b89\u88c5\u5e93<\/h3>\n<\/p>\n<p><p>\u5f53\u4f60\u5728Pycharm\u4e2d\u8fdb\u884c\u5f00\u53d1\u65f6\uff0c\u5b89\u88c5\u5e93\u662f\u975e\u5e38\u91cd\u8981\u7684\u4e00\u6b65\u3002Pycharm\u63d0\u4f9b\u4e86\u4e00\u4e2a\u76f4\u89c2\u7684\u754c\u9762\u6765\u5e2e\u52a9\u4f60\u5b89\u88c5\u548c\u7ba1\u7406\u5e93\u3002\u6253\u5f00Pycharm\u4e4b\u540e\uff0c\u70b9\u51fb\u201cFile\u201d -&gt; \u201cSettings\u201d\uff0c\u7136\u540e\u5728\u5f39\u51fa\u7684\u8bbe\u7f6e\u7a97\u53e3\u4e2d\u627e\u5230\u201cProject: &lt;\u4f60\u7684\u9879\u76ee\u540d\u79f0&gt;\u201d -&gt; \u201cPython Interpreter\u201d\u3002\u5728\u8fd9\u91cc\uff0c\u4f60\u53ef\u4ee5\u770b\u5230\u5f53\u524d\u9879\u76ee\u4e2d\u5df2\u7ecf\u5b89\u88c5\u7684\u6240\u6709\u5e93\u3002<\/p>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u754c\u9762\u4e2d\uff0c\u4f60\u53ef\u4ee5\u70b9\u51fb\u53f3\u4fa7\u7684\u201c+\u201d\u6309\u94ae\u6765\u6dfb\u52a0\u65b0\u7684\u5e93\u3002\u70b9\u51fb\u540e\uff0c\u4f1a\u5f39\u51fa\u4e00\u4e2a\u65b0\u7684\u7a97\u53e3\uff0c\u4f60\u53ef\u4ee5\u5728\u641c\u7d22\u680f\u4e2d\u8f93\u5165\u4f60\u60f3\u8981\u5b89\u88c5\u7684\u5e93\u7684\u540d\u5b57\u3002\u6bd4\u5982\uff0c\u5982\u679c\u4f60\u60f3\u5b89\u88c5<code>pandas<\/code>\u5e93\uff0c\u53ea\u9700\u8981\u5728\u641c\u7d22\u680f\u4e2d\u8f93\u5165\u201cpandas\u201d\uff0c\u7136\u540e\u70b9\u51fb\u201cInstall Package\u201d\u6309\u94ae\u3002Pycharm\u4f1a\u81ea\u52a8\u4e0b\u8f7d\u5e76\u5b89\u88c5\u8fd9\u4e2a\u5e93\u3002<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u5e93\u7684\u8fc7\u7a0b\u53ef\u80fd\u9700\u8981\u4e00\u4e9b\u65f6\u95f4\uff0c\u5177\u4f53\u53d6\u51b3\u4e8e\u4f60\u7684\u7f51\u7edc\u73af\u5883\u548c\u5e93\u7684\u5927\u5c0f\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u5728\u201cPython Interpreter\u201d\u754c\u9762\u4e2d\u770b\u5230\u65b0\u5b89\u88c5\u7684\u5e93\u3002\u8fd9\u6837\uff0c\u4f60\u5c31\u53ef\u4ee5\u5728\u4f60\u7684\u9879\u76ee\u4e2d\u4f7f\u7528\u8fd9\u4e2a\u5e93\u4e86\u3002<\/p>\n<\/p>\n<p><h3>\u5bfc\u5165\u5e93\u4e0e\u4f7f\u7528\u5e93<\/h3>\n<\/p>\n<p><p>\u5b89\u88c5\u597d\u5e93\u4e4b\u540e\uff0c\u5728\u4ee3\u7801\u4e2d\u4f7f\u7528\u8fd9\u4e9b\u5e93\u662f\u975e\u5e38\u7b80\u5355\u7684\u3002\u4f60\u53ea\u9700\u8981\u5728\u4ee3\u7801\u7684\u5f00\u5934\u4f7f\u7528<code>import<\/code>\u8bed\u53e5\u5bfc\u5165\u5e93\uff0c\u7136\u540e\u5c31\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e2a\u5e93\u63d0\u4f9b\u7684\u529f\u80fd\u3002\u4f8b\u5982\uff0c\u5047\u8bbe\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86<code>matplotlib<\/code>\u5e93\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u4ee3\u7801\u6765\u5bfc\u5165\u5e76\u4f7f\u7528\u5b83\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<h2><strong>\u521b\u5efa\u6570\u636e<\/strong><\/h2>\n<p>x = [1, 2, 3, 4, 5]<\/p>\n<p>y = [10, 20, 25, 30, 35]<\/p>\n<h2><strong>\u7ed8\u5236\u6298\u7ebf\u56fe<\/strong><\/h2>\n<p>plt.plot(x, y)<\/p>\n<p>plt.xlabel(&#39;X axis&#39;)<\/p>\n<p>plt.ylabel(&#39;Y axis&#39;)<\/p>\n<p>plt.title(&#39;Sample Plot&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u5bfc\u5165\u4e86<code>matplotlib.pyplot<\/code>\u6a21\u5757\uff0c\u5e76\u5c06\u5b83\u91cd\u547d\u540d\u4e3a<code>plt<\/code>\u3002\u7136\u540e\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e24\u4e2a\u5217\u8868<code>x<\/code>\u548c<code>y<\/code>\uff0c\u5206\u522b\u8868\u793a\u6a2a\u5750\u6807\u548c\u7eb5\u5750\u6807\u7684\u6570\u636e\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u4f7f\u7528<code>plt.plot<\/code>\u51fd\u6570\u7ed8\u5236\u6298\u7ebf\u56fe\uff0c\u5e76\u4f7f\u7528<code>plt.xlabel<\/code>\u3001<code>plt.ylabel<\/code>\u548c<code>plt.title<\/code>\u51fd\u6570\u8bbe\u7f6e\u56fe\u8868\u7684\u6807\u7b7e\u548c\u6807\u9898\u3002\u6700\u540e\uff0c\u4f7f\u7528<code>plt.show<\/code>\u51fd\u6570\u663e\u793a\u56fe\u8868\u3002<\/p>\n<\/p>\n<p><h3>\u8c03\u8bd5\u4ee3\u7801<\/h3>\n<\/p>\n<p><p>Pycharm\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u8c03\u8bd5\u529f\u80fd\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u53d1\u73b0\u548c\u4fee\u590d\u4ee3\u7801\u4e2d\u7684\u9519\u8bef\u3002\u8c03\u8bd5\u4ee3\u7801\u7684\u7b2c\u4e00\u6b65\u662f\u8bbe\u7f6e\u65ad\u70b9\u3002\u65ad\u70b9\u662f\u4ee3\u7801\u6267\u884c\u8fc7\u7a0b\u4e2d\u4f1a\u6682\u505c\u7684\u5730\u65b9\uff0c\u4f60\u53ef\u4ee5\u5728\u8fd9\u4e2a\u5730\u65b9\u68c0\u67e5\u53d8\u91cf\u7684\u503c\u548c\u7a0b\u5e8f\u7684\u72b6\u6001\u3002\u4f60\u53ef\u4ee5\u5728\u4ee3\u7801\u884c\u53f7\u7684\u5de6\u4fa7\u70b9\u51fb\uff0c\u8bbe\u7f6e\u4e00\u4e2a\u7ea2\u8272\u7684\u65ad\u70b9\u3002<\/p>\n<\/p>\n<p><p>\u8bbe\u7f6e\u597d\u65ad\u70b9\u4e4b\u540e\uff0c\u70b9\u51fbPycharm\u5de5\u5177\u680f\u4e2d\u7684\u201cDebug\u201d\u6309\u94ae\uff0c\u6216\u8005\u6309Shift + F9\u5f00\u59cb\u8c03\u8bd5\u3002\u5728\u8c03\u8bd5\u6a21\u5f0f\u4e0b\uff0cPycharm\u4f1a\u5728\u4f60\u8bbe\u7f6e\u7684\u65ad\u70b9\u5904\u6682\u505c\u7a0b\u5e8f\u7684\u6267\u884c\uff0c\u4f60\u53ef\u4ee5\u67e5\u770b\u5f53\u524d\u7684\u53d8\u91cf\u503c\u548c\u7a0b\u5e8f\u7684\u72b6\u6001\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u8c03\u8bd5\u5de5\u5177\u680f\u4e2d\u7684\u6309\u94ae\u6765\u5355\u6b65\u6267\u884c\u4ee3\u7801\u3001\u7ee7\u7eed\u8fd0\u884c\u7a0b\u5e8f\u6216\u8005\u7ec8\u6b62\u8c03\u8bd5\u3002<\/p>\n<\/p>\n<p><p>\u8c03\u8bd5\u5de5\u5177\u680f\u4e2d\u7684\u201cStep Over\u201d\u6309\u94ae\uff08\u5feb\u6377\u952e\u4e3aF8\uff09\u53ef\u4ee5\u8ba9\u4f60\u5355\u6b65\u6267\u884c\u4ee3\u7801\uff0c\u4e0d\u4f1a\u8fdb\u5165\u51fd\u6570\u5185\u90e8\uff1b\u201cStep Into\u201d\u6309\u94ae\uff08\u5feb\u6377\u952e\u4e3aF7\uff09\u53ef\u4ee5\u8ba9\u4f60\u8fdb\u5165\u51fd\u6570\u5185\u90e8\u67e5\u770b\u8be6\u7ec6\u7684\u6267\u884c\u8fc7\u7a0b\uff1b\u201cStep Out\u201d\u6309\u94ae\uff08\u5feb\u6377\u952e\u4e3aShift + F8\uff09\u53ef\u4ee5\u8ba9\u4f60\u8df3\u51fa\u5f53\u524d\u51fd\u6570\uff0c\u7ee7\u7eed\u6267\u884c\u540e\u7eed\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u8c03\u8bd5\u4ee3\u7801\uff0c\u4f60\u53ef\u4ee5\u66f4\u597d\u5730\u7406\u89e3\u7a0b\u5e8f\u7684\u6267\u884c\u8fc7\u7a0b\uff0c\u53d1\u73b0\u5e76\u4fee\u590d\u4ee3\u7801\u4e2d\u7684\u9519\u8bef\uff0c\u63d0\u9ad8\u4ee3\u7801\u7684\u8d28\u91cf\u548c\u7a33\u5b9a\u6027\u3002<\/p>\n<\/p>\n<p><h3>\u4f7f\u7528Python\u5e93\u8fdb\u884c\u6570\u636e\u5206\u6790<\/h3>\n<\/p>\n<p><p>Python\u5e93\u5728\u6570\u636e\u5206\u6790\u9886\u57df\u6709\u7740\u5e7f\u6cdb\u7684\u5e94\u7528\u3002\u5e38\u7528\u7684\u5e93\u5305\u62ec<code>pandas<\/code>\u3001<code>numpy<\/code>\u3001<code>matplotlib<\/code>\u548c<code>seaborn<\/code>\u7b49\u3002\u8fd9\u4e9b\u5e93\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u529f\u80fd\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u9ad8\u6548\u5730\u8fdb\u884c\u6570\u636e\u5904\u7406\u548c\u5206\u6790\u3002<\/p>\n<\/p>\n<p><h4>\u4f7f\u7528Pandas\u8fdb\u884c\u6570\u636e\u5904\u7406<\/h4>\n<\/p>\n<p><p><code>pandas<\/code>\u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684\u6570\u636e\u5904\u7406\u5e93\uff0c\u5b83\u63d0\u4f9b\u4e86\u6570\u636e\u7ed3\u6784\u548c\u6570\u636e\u5206\u6790\u5de5\u5177\u3002<code>pandas<\/code>\u7684\u6838\u5fc3\u6570\u636e\u7ed3\u6784\u662f<code>DataFrame<\/code>\uff0c\u5b83\u7c7b\u4f3c\u4e8eExcel\u4e2d\u7684\u8868\u683c\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u8fdb\u884c\u6570\u636e\u7684\u589e\u5220\u6539\u67e5\u3001\u6570\u636e\u6e05\u6d17\u548c\u6570\u636e\u8f6c\u6362\u7b49\u64cd\u4f5c\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u521b\u5efa\u6570\u636e<\/strong><\/h2>\n<p>data = {<\/p>\n<p>    &#39;Name&#39;: [&#39;Alice&#39;, &#39;Bob&#39;, &#39;Charlie&#39;, &#39;David&#39;, &#39;Eva&#39;],<\/p>\n<p>    &#39;Age&#39;: [25, 30, 35, 40, 45],<\/p>\n<p>    &#39;City&#39;: [&#39;New York&#39;, &#39;Los Angeles&#39;, &#39;Chicago&#39;, &#39;Houston&#39;, &#39;Phoenix&#39;]<\/p>\n<p>}<\/p>\n<p>df = pd.DataFrame(data)<\/p>\n<h2><strong>\u67e5\u770b\u6570\u636e<\/strong><\/h2>\n<p>print(df)<\/p>\n<h2><strong>\u7b5b\u9009\u5e74\u9f84\u5927\u4e8e30\u7684\u4eba<\/strong><\/h2>\n<p>filtered_df = df[df[&#39;Age&#39;] &gt; 30]<\/p>\n<p>print(filtered_df)<\/p>\n<h2><strong>\u8ba1\u7b97\u5e74\u9f84\u7684\u5e73\u5747\u503c<\/strong><\/h2>\n<p>mean_age = df[&#39;Age&#39;].mean()<\/p>\n<p>print(f&quot;Mean age: {mean_age}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u5bfc\u5165\u4e86<code>pandas<\/code>\u5e93\uff0c\u5e76\u521b\u5efa\u4e86\u4e00\u4e2a\u5305\u542b\u4eba\u5458\u4fe1\u606f\u7684\u6570\u636e\u5b57\u5178\u3002\u7136\u540e\uff0c\u6211\u4eec\u4f7f\u7528<code>pd.DataFrame<\/code>\u51fd\u6570\u5c06\u6570\u636e\u5b57\u5178\u8f6c\u6362\u4e3a<code>DataFrame<\/code>\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<code>DataFrame<\/code>\u5bf9\u8c61\u7684\u65b9\u6cd5\u548c\u5c5e\u6027\u6765\u8fdb\u884c\u6570\u636e\u64cd\u4f5c\u3002\u4f8b\u5982\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<code>print<\/code>\u51fd\u6570\u67e5\u770b\u6570\u636e\uff0c\u4f7f\u7528\u6761\u4ef6\u7b5b\u9009\u7b5b\u9009\u51fa\u5e74\u9f84\u5927\u4e8e30\u7684\u4eba\uff0c\u4f7f\u7528<code>mean<\/code>\u65b9\u6cd5\u8ba1\u7b97\u5e74\u9f84\u7684\u5e73\u5747\u503c\u3002<\/p>\n<\/p>\n<p><h4>\u4f7f\u7528Numpy\u8fdb\u884c\u6570\u503c\u8ba1\u7b97<\/h4>\n<\/p>\n<p><p><code>numpy<\/code>\u662f\u4e00\u4e2a\u9ad8\u6027\u80fd\u7684\u79d1\u5b66\u8ba1\u7b97\u5e93\uff0c\u5b83\u63d0\u4f9b\u4e86\u591a\u7ef4\u6570\u7ec4\u5bf9\u8c61\u548c\u5404\u79cd\u6570\u503c\u8ba1\u7b97\u529f\u80fd\u3002<code>numpy<\/code>\u6570\u7ec4\u6bd4Python\u5185\u7f6e\u7684\u5217\u8868\u66f4\u9ad8\u6548\uff0c\u9002\u5408\u5904\u7406\u5927\u89c4\u6a21\u7684\u6570\u636e\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u7ef4\u6570\u7ec4<\/strong><\/h2>\n<p>arr = np.array([1, 2, 3, 4, 5])<\/p>\n<p>print(arr)<\/p>\n<h2><strong>\u521b\u5efa\u4e8c\u7ef4\u6570\u7ec4<\/strong><\/h2>\n<p>arr_2d = np.array([[1, 2, 3], [4, 5, 6]])<\/p>\n<p>print(arr_2d)<\/p>\n<h2><strong>\u4f7f\u7528numpy\u8fdb\u884c\u6570\u5b66\u8fd0\u7b97<\/strong><\/h2>\n<p>sum_arr = np.sum(arr)<\/p>\n<p>mean_arr = np.mean(arr)<\/p>\n<p>std_arr = np.std(arr)<\/p>\n<p>print(f&quot;Sum of array: {sum_arr}&quot;)<\/p>\n<p>print(f&quot;Mean of array: {mean_arr}&quot;)<\/p>\n<p>print(f&quot;Standard deviation of array: {std_arr}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u5bfc\u5165\u4e86<code>numpy<\/code>\u5e93\uff0c\u5e76\u521b\u5efa\u4e86\u4e00\u7ef4\u6570\u7ec4\u548c\u4e8c\u7ef4\u6570\u7ec4\u3002\u7136\u540e\uff0c\u6211\u4eec\u4f7f\u7528<code>numpy<\/code>\u63d0\u4f9b\u7684<code>sum<\/code>\u3001<code>mean<\/code>\u548c<code>std<\/code>\u51fd\u6570\u5206\u522b\u8ba1\u7b97\u6570\u7ec4\u7684\u548c\u3001\u5747\u503c\u548c\u6807\u51c6\u5dee\u3002<\/p>\n<\/p>\n<p><h3>\u6570\u636e\u53ef\u89c6\u5316<\/h3>\n<\/p>\n<p><p>\u6570\u636e\u53ef\u89c6\u5316\u662f\u6570\u636e\u5206\u6790\u7684\u91cd\u8981\u7ec4\u6210\u90e8\u5206\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u66f4\u76f4\u89c2\u5730\u7406\u89e3\u6570\u636e\u3002\u5e38\u7528\u7684\u6570\u636e\u53ef\u89c6\u5316\u5e93\u5305\u62ec<code>matplotlib<\/code>\u548c<code>seaborn<\/code>\u7b49\u3002<\/p>\n<\/p>\n<p><h4>\u4f7f\u7528Matplotlib\u8fdb\u884c\u6570\u636e\u53ef\u89c6\u5316<\/h4>\n<\/p>\n<p><p><code>matplotlib<\/code>\u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684\u6570\u636e\u53ef\u89c6\u5316\u5e93\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u7ed8\u56fe\u529f\u80fd\uff0c\u53ef\u4ee5\u7ed8\u5236\u6298\u7ebf\u56fe\u3001\u67f1\u72b6\u56fe\u3001\u6563\u70b9\u56fe\u3001\u76f4\u65b9\u56fe\u7b49\u5404\u79cd\u56fe\u8868\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<h2><strong>\u521b\u5efa\u6570\u636e<\/strong><\/h2>\n<p>x = [1, 2, 3, 4, 5]<\/p>\n<p>y = [10, 20, 25, 30, 35]<\/p>\n<h2><strong>\u7ed8\u5236\u6298\u7ebf\u56fe<\/strong><\/h2>\n<p>plt.plot(x, y)<\/p>\n<p>plt.xlabel(&#39;X axis&#39;)<\/p>\n<p>plt.ylabel(&#39;Y axis&#39;)<\/p>\n<p>plt.title(&#39;Sample Plot&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u5bfc\u5165\u4e86<code>matplotlib.pyplot<\/code>\u6a21\u5757\uff0c\u5e76\u5c06\u5b83\u91cd\u547d\u540d\u4e3a<code>plt<\/code>\u3002\u7136\u540e\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e24\u4e2a\u5217\u8868<code>x<\/code>\u548c<code>y<\/code>\uff0c\u5206\u522b\u8868\u793a\u6a2a\u5750\u6807\u548c\u7eb5\u5750\u6807\u7684\u6570\u636e\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u4f7f\u7528<code>plt.plot<\/code>\u51fd\u6570\u7ed8\u5236\u6298\u7ebf\u56fe\uff0c\u5e76\u4f7f\u7528<code>plt.xlabel<\/code>\u3001<code>plt.ylabel<\/code>\u548c<code>plt.title<\/code>\u51fd\u6570\u8bbe\u7f6e\u56fe\u8868\u7684\u6807\u7b7e\u548c\u6807\u9898\u3002\u6700\u540e\uff0c\u4f7f\u7528<code>plt.show<\/code>\u51fd\u6570\u663e\u793a\u56fe\u8868\u3002<\/p>\n<\/p>\n<p><h4>\u4f7f\u7528Seaborn\u8fdb\u884c\u9ad8\u7ea7\u6570\u636e\u53ef\u89c6\u5316<\/h4>\n<\/p>\n<p><p><code>seaborn<\/code>\u662f\u4e00\u4e2a\u57fa\u4e8e<code>matplotlib<\/code>\u7684\u9ad8\u7ea7\u6570\u636e\u53ef\u89c6\u5316\u5e93\uff0c\u5b83\u63d0\u4f9b\u4e86\u66f4\u52a0\u7b80\u6d01\u548c\u7f8e\u89c2\u7684\u7ed8\u56fe\u63a5\u53e3\uff0c\u9002\u5408\u8fdb\u884c\u7edf\u8ba1\u6570\u636e\u7684\u53ef\u89c6\u5316\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import seaborn as sns<\/p>\n<p>import pandas as pd<\/p>\n<h2><strong>\u521b\u5efa\u6570\u636e<\/strong><\/h2>\n<p>data = {<\/p>\n<p>    &#39;Name&#39;: [&#39;Alice&#39;, &#39;Bob&#39;, &#39;Charlie&#39;, &#39;David&#39;, &#39;Eva&#39;],<\/p>\n<p>    &#39;Age&#39;: [25, 30, 35, 40, 45],<\/p>\n<p>    &#39;City&#39;: [&#39;New York&#39;, &#39;Los Angeles&#39;, &#39;Chicago&#39;, &#39;Houston&#39;, &#39;Phoenix&#39;]<\/p>\n<p>}<\/p>\n<p>df = pd.DataFrame(data)<\/p>\n<h2><strong>\u7ed8\u5236\u6761\u5f62\u56fe<\/strong><\/h2>\n<p>sns.barplot(x=&#39;Name&#39;, y=&#39;Age&#39;, data=df)<\/p>\n<p>plt.xlabel(&#39;Name&#39;)<\/p>\n<p>plt.ylabel(&#39;Age&#39;)<\/p>\n<p>plt.title(&#39;Age of Individuals&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u5bfc\u5165\u4e86<code>seaborn<\/code>\u5e93\u548c<code>pandas<\/code>\u5e93\uff0c\u5e76\u521b\u5efa\u4e86\u4e00\u4e2a\u5305\u542b\u4eba\u5458\u4fe1\u606f\u7684\u6570\u636e\u5b57\u5178\u3002\u7136\u540e\uff0c\u6211\u4eec\u4f7f\u7528<code>pd.DataFrame<\/code>\u51fd\u6570\u5c06\u6570\u636e\u5b57\u5178\u8f6c\u6362\u4e3a<code>DataFrame<\/code>\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u4f7f\u7528<code>seaborn<\/code>\u7684<code>barplot<\/code>\u51fd\u6570\u7ed8\u5236\u6761\u5f62\u56fe\uff0c\u5e76\u4f7f\u7528<code>plt.xlabel<\/code>\u3001<code>plt.ylabel<\/code>\u548c<code>plt.title<\/code>\u51fd\u6570\u8bbe\u7f6e\u56fe\u8868\u7684\u6807\u7b7e\u548c\u6807\u9898\u3002\u6700\u540e\uff0c\u4f7f\u7528<code>plt.show<\/code>\u51fd\u6570\u663e\u793a\u56fe\u8868\u3002<\/p>\n<\/p>\n<p><h3>\u4f7f\u7528Python\u5e93\u8fdb\u884c<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a><\/h3>\n<\/p>\n<p><p>Python\u5e93\u5728\u673a\u5668\u5b66\u4e60\u9886\u57df\u6709\u7740\u5e7f\u6cdb\u7684\u5e94\u7528\u3002\u5e38\u7528\u7684\u5e93\u5305\u62ec<code>scikit-learn<\/code>\u3001<code>tensorflow<\/code>\u3001<code>keras<\/code>\u548c<code>pytorch<\/code>\u7b49\u3002\u8fd9\u4e9b\u5e93\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u529f\u80fd\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u9ad8\u6548\u5730\u8fdb\u884c\u673a\u5668\u5b66\u4e60\u6a21\u578b\u7684\u6784\u5efa\u3001\u8bad\u7ec3\u548c\u8bc4\u4f30\u3002<\/p>\n<\/p>\n<p><h4>\u4f7f\u7528Scikit-learn\u8fdb\u884c\u673a\u5668\u5b66\u4e60<\/h4>\n<\/p>\n<p><p><code>scikit-learn<\/code>\u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684\u673a\u5668\u5b66\u4e60\u5e93\uff0c\u5b83\u63d0\u4f9b\u4e86\u5404\u79cd\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\u548c\u5de5\u5177\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u8fdb\u884c\u6570\u636e\u9884\u5904\u7406\u3001\u6a21\u578b\u8bad\u7ec3\u548c\u6a21\u578b\u8bc4\u4f30\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from sklearn.datasets import load_iris<\/p>\n<p>from sklearn.model_selection import tr<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>n_test_split<\/p>\n<p>from sklearn.ensemble import RandomForestClassifier<\/p>\n<p>from sklearn.metrics import accuracy_score<\/p>\n<h2><strong>\u52a0\u8f7d\u6570\u636e\u96c6<\/strong><\/h2>\n<p>iris = load_iris()<\/p>\n<p>X = iris.data<\/p>\n<p>y = iris.target<\/p>\n<h2><strong>\u5212\u5206\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6<\/strong><\/h2>\n<p>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)<\/p>\n<h2><strong>\u521b\u5efa\u968f\u673a\u68ee\u6797\u5206\u7c7b\u5668<\/strong><\/h2>\n<p>clf = RandomForestClassifier(n_estimators=100)<\/p>\n<h2><strong>\u8bad\u7ec3\u6a21\u578b<\/strong><\/h2>\n<p>clf.fit(X_train, y_train)<\/p>\n<h2><strong>\u9884\u6d4b<\/strong><\/h2>\n<p>y_pred = clf.predict(X_test)<\/p>\n<h2><strong>\u8ba1\u7b97\u51c6\u786e\u7387<\/strong><\/h2>\n<p>accuracy = accuracy_score(y_test, y_pred)<\/p>\n<p>print(f&quot;Accuracy: {accuracy}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u5bfc\u5165\u4e86<code>scikit-learn<\/code>\u5e93\u4e2d\u7684\u5404\u79cd\u6a21\u5757\u548c\u51fd\u6570\uff0c\u5e76\u52a0\u8f7d\u4e86<code>iris<\/code>\u6570\u636e\u96c6\u3002\u7136\u540e\uff0c\u6211\u4eec\u4f7f\u7528<code>train_test_split<\/code>\u51fd\u6570\u5c06\u6570\u636e\u96c6\u5212\u5206\u4e3a\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u968f\u673a\u68ee\u6797\u5206\u7c7b\u5668\uff0c\u5e76\u4f7f\u7528\u8bad\u7ec3\u96c6\u6570\u636e\u8bad\u7ec3\u6a21\u578b\u3002\u8bad\u7ec3\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u4f7f\u7528\u6d4b\u8bd5\u96c6\u6570\u636e\u8fdb\u884c\u9884\u6d4b\uff0c\u5e76\u4f7f\u7528<code>accuracy_score<\/code>\u51fd\u6570\u8ba1\u7b97\u6a21\u578b\u7684\u51c6\u786e\u7387\u3002<\/p>\n<\/p>\n<p><h4>\u4f7f\u7528TensorFlow\u8fdb\u884c\u6df1\u5ea6\u5b66\u4e60<\/h4>\n<\/p>\n<p><p><code>tensorflow<\/code>\u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6\uff0c\u5b83\u63d0\u4f9b\u4e86\u5404\u79cd\u5de5\u5177\u548c\u63a5\u53e3\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u6784\u5efa\u3001\u8bad\u7ec3\u548c\u90e8\u7f72\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import tensorflow as tf<\/p>\n<p>from tensorflow.keras.models import Sequential<\/p>\n<p>from tensorflow.keras.layers import Dense<\/p>\n<p>from sklearn.datasets import load_iris<\/p>\n<p>from sklearn.model_selection import train_test_split<\/p>\n<p>from sklearn.preprocessing import OneHotEncoder<\/p>\n<h2><strong>\u52a0\u8f7d\u6570\u636e\u96c6<\/strong><\/h2>\n<p>iris = load_iris()<\/p>\n<p>X = iris.data<\/p>\n<p>y = iris.target<\/p>\n<h2><strong>\u72ec\u70ed\u7f16\u7801<\/strong><\/h2>\n<p>encoder = OneHotEncoder(sparse=False)<\/p>\n<p>y = encoder.fit_transform(y.reshape(-1, 1))<\/p>\n<h2><strong>\u5212\u5206\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6<\/strong><\/h2>\n<p>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)<\/p>\n<h2><strong>\u6784\u5efa\u6a21\u578b<\/strong><\/h2>\n<p>model = Sequential()<\/p>\n<p>model.add(Dense(10, input_dim=4, activation=&#39;relu&#39;))<\/p>\n<p>model.add(Dense(3, activation=&#39;softmax&#39;))<\/p>\n<h2><strong>\u7f16\u8bd1\u6a21\u578b<\/strong><\/h2>\n<p>model.compile(loss=&#39;categorical_crossentropy&#39;, optimizer=&#39;adam&#39;, metrics=[&#39;accuracy&#39;])<\/p>\n<h2><strong>\u8bad\u7ec3\u6a21\u578b<\/strong><\/h2>\n<p>model.fit(X_train, y_train, epochs=50, batch_size=5, verbose=1)<\/p>\n<h2><strong>\u8bc4\u4f30\u6a21\u578b<\/strong><\/h2>\n<p>loss, accuracy = model.evaluate(X_test, y_test)<\/p>\n<p>print(f&quot;Loss: {loss}, Accuracy: {accuracy}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u5bfc\u5165\u4e86<code>tensorflow<\/code>\u5e93\u548c<code>scikit-learn<\/code>\u5e93\u4e2d\u7684\u5404\u79cd\u6a21\u5757\u548c\u51fd\u6570\uff0c\u5e76\u52a0\u8f7d\u4e86<code>iris<\/code>\u6570\u636e\u96c6\u3002\u7136\u540e\uff0c\u6211\u4eec\u4f7f\u7528<code>OneHotEncoder<\/code>\u8fdb\u884c\u72ec\u70ed\u7f16\u7801\uff0c\u5c06\u76ee\u6807\u53d8\u91cf\u8f6c\u6362\u4e3a\u72ec\u70ed\u7f16\u7801\u5f62\u5f0f\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u4f7f\u7528<code>train_test_split<\/code>\u51fd\u6570\u5c06\u6570\u636e\u96c6\u5212\u5206\u4e3a\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6\u3002<\/p>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u4f7f\u7528<code>Sequential<\/code>\u7c7b\u6784\u5efa\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u795e\u7ecf\u7f51\u7edc\u6a21\u578b\u3002\u6a21\u578b\u5305\u542b\u4e24\u4e2a\u5168\u8fde\u63a5\u5c42\uff0c\u7b2c\u4e00\u4e2a\u5168\u8fde\u63a5\u5c42\u670910\u4e2a\u795e\u7ecf\u5143\uff0c\u4f7f\u7528ReLU\u6fc0\u6d3b\u51fd\u6570\uff1b\u7b2c\u4e8c\u4e2a\u5168\u8fde\u63a5\u5c42\u67093\u4e2a\u795e\u7ecf\u5143\uff0c\u4f7f\u7528softmax\u6fc0\u6d3b\u51fd\u6570\u3002\u7136\u540e\uff0c\u6211\u4eec\u4f7f\u7528<code>compile<\/code>\u65b9\u6cd5\u7f16\u8bd1\u6a21\u578b\uff0c\u6307\u5b9a\u635f\u5931\u51fd\u6570\u3001\u4f18\u5316\u5668\u548c\u8bc4\u4f30\u6307\u6807\u3002<\/p>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u4f7f\u7528<code>fit<\/code>\u65b9\u6cd5\u8bad\u7ec3\u6a21\u578b\uff0c\u6307\u5b9a\u8bad\u7ec3\u96c6\u6570\u636e\u3001\u8bad\u7ec3\u8f6e\u6570\u3001\u6279\u6b21\u5927\u5c0f\u548c\u65e5\u5fd7\u663e\u793a\u7ea7\u522b\u3002\u8bad\u7ec3\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u4f7f\u7528<code>evaluate<\/code>\u65b9\u6cd5\u8bc4\u4f30\u6a21\u578b\uff0c\u8ba1\u7b97\u6a21\u578b\u5728\u6d4b\u8bd5\u96c6\u4e0a\u7684\u635f\u5931\u548c\u51c6\u786e\u7387\u3002<\/p>\n<\/p>\n<p><h3>\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u5728Pycharm\u4e2d\u4f7f\u7528Python\u5e93\u8fdb\u884c\u5f00\u53d1\u548c\u6570\u636e\u5206\u6790\u662f\u975e\u5e38\u65b9\u4fbf\u548c\u9ad8\u6548\u7684\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7Pycharm\u7684\u5185\u7f6e\u529f\u80fd\u5b89\u88c5\u548c\u7ba1\u7406\u5e93\uff0c\u4f7f\u7528<code>import<\/code>\u8bed\u53e5\u5bfc\u5165\u5e93\uff0c\u5e76\u5728\u4ee3\u7801\u4e2d\u4f7f\u7528\u8fd9\u4e9b\u5e93\u63d0\u4f9b\u7684\u529f\u80fd\u3002Pycharm\u8fd8\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u8c03\u8bd5\u5de5\u5177\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u53d1\u73b0\u548c\u4fee\u590d\u4ee3\u7801\u4e2d\u7684\u9519\u8bef\u3002<\/p>\n<\/p>\n<p><p>\u5728\u6570\u636e\u5206\u6790\u9886\u57df\uff0c\u5e38\u7528\u7684\u5e93\u5305\u62ec<code>pandas<\/code>\u3001<code>numpy<\/code>\u3001<code>matplotlib<\/code>\u548c<code>seaborn<\/code>\u7b49\u3002\u8fd9\u4e9b\u5e93\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u529f\u80fd\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u9ad8\u6548\u5730\u8fdb\u884c\u6570\u636e\u5904\u7406\u3001\u6570\u503c\u8ba1\u7b97\u548c\u6570\u636e\u53ef\u89c6\u5316\u3002\u5728\u673a\u5668\u5b66\u4e60\u9886\u57df\uff0c\u5e38\u7528\u7684\u5e93\u5305\u62ec<code>scikit-learn<\/code>\u3001<code>tensorflow<\/code>\u3001<code>keras<\/code>\u548c<code>pytorch<\/code>\u7b49\u3002\u8fd9\u4e9b\u5e93\u63d0\u4f9b\u4e86\u5404\u79cd\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\u548c\u5de5\u5177\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u9ad8\u6548\u5730\u6784\u5efa\u3001\u8bad\u7ec3\u548c\u8bc4\u4f30\u673a\u5668\u5b66\u4e60\u6a21\u578b\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u672c\u6587\u7684\u4ecb\u7ecd\uff0c\u4f60\u5e94\u8be5\u5bf9\u5982\u4f55\u5728Pycharm\u4e2d\u4f7f\u7528Python\u7684\u5e93\u6709\u4e86\u4e00\u4e2a\u6bd4\u8f83\u5168\u9762\u7684\u4e86\u89e3\u3002\u5e0c\u671b\u8fd9\u4e9b\u5185\u5bb9\u80fd\u5bf9\u4f60\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d\u6709\u6240\u5e2e\u52a9\uff0c\u63d0\u9ad8\u4f60\u7684\u5f00\u53d1\u6548\u7387\u548c\u4ee3\u7801\u8d28\u91cf\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728PyCharm\u4e2d\u5b89\u88c5Python\u5e93\uff1f<\/strong><br \/>\u5728PyCharm\u4e2d\u5b89\u88c5Python\u5e93\u975e\u5e38\u7b80\u5355\u3002\u6253\u5f00\u4f60\u7684\u9879\u76ee\uff0c\u8fdb\u5165\u201cFile\u201d\u83dc\u5355\uff0c\u9009\u62e9\u201cSettings\u201d\u6216\u201cPreferences\u201d\uff08\u53d6\u51b3\u4e8e\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\uff09\u3002\u5728\u5de6\u4fa7\u83dc\u5355\u4e2d\u627e\u5230\u201cProject: [\u4f60\u7684\u9879\u76ee\u540d]\u201d\uff0c\u7136\u540e\u70b9\u51fb\u201cPython Interpreter\u201d\u3002\u5728\u53f3\u4fa7\u7684\u7a97\u53e3\u4e2d\uff0c\u4f60\u4f1a\u770b\u5230\u4e00\u4e2a\u5e93\u5217\u8868\uff0c\u70b9\u51fb\u201c+\u201d\u6309\u94ae\uff0c\u641c\u7d22\u4f60\u60f3\u8981\u5b89\u88c5\u7684\u5e93\uff0c\u9009\u62e9\u540e\u70b9\u51fb\u201cInstall Package\u201d\u5373\u53ef\u3002<\/p>\n<p><strong>\u5728PyCharm\u4e2d\u5982\u4f55\u4f7f\u7528\u5df2\u5b89\u88c5\u7684Python\u5e93\uff1f<\/strong><br \/>\u4f7f\u7528\u5df2\u5b89\u88c5\u7684Python\u5e93\u4e5f\u5f88\u7b80\u5355\u3002\u5728\u4f60\u7684Python\u6587\u4ef6\u4e2d\uff0c\u4f7f\u7528<code>import<\/code>\u8bed\u53e5\u5f15\u5165\u5e93\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4f60\u5b89\u88c5\u4e86<code>numpy<\/code>\u5e93\uff0c\u53ef\u4ee5\u5728\u4ee3\u7801\u4e2d\u4f7f\u7528<code>import numpy as np<\/code>\u6765\u5f15\u5165\u3002\u786e\u4fdd\u5728\u4ee3\u7801\u6267\u884c\u73af\u5883\u4e2d\u9009\u62e9\u4e86\u6b63\u786e\u7684Python\u89e3\u91ca\u5668\uff0c\u8fd9\u6837\u624d\u80fd\u786e\u4fdd\u5e93\u80fd\u591f\u6b63\u5e38\u4f7f\u7528\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728PyCharm\u4e2d\u7ba1\u7406\u4e0d\u540c\u9879\u76ee\u7684Python\u5e93\uff1f<\/strong><br \/>\u4e3a\u4e86\u6709\u6548\u7ba1\u7406\u4e0d\u540c\u9879\u76ee\u7684Python\u5e93\uff0c\u4f60\u53ef\u4ee5\u4e3a\u6bcf\u4e2a\u9879\u76ee\u521b\u5efa\u4e00\u4e2a\u865a\u62df\u73af\u5883\u3002\u5728PyCharm\u4e2d\uff0c\u521b\u5efa\u65b0\u9879\u76ee\u65f6\uff0c\u9009\u62e9\u201cNew environment\u201d\u9009\u9879\uff0cPyCharm\u4f1a\u81ea\u52a8\u4e3a\u8be5\u9879\u76ee\u751f\u6210\u4e00\u4e2a\u72ec\u7acb\u7684\u865a\u62df\u73af\u5883\u3002\u8fd9\u6837\uff0c\u4f60\u53ef\u4ee5\u5728\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u4f7f\u7528\u4e0d\u540c\u7248\u672c\u7684\u5e93\uff0c\u907f\u514d\u7248\u672c\u51b2\u7a81\u3002\u8981\u67e5\u770b\u6216\u5207\u6362\u865a\u62df\u73af\u5883\uff0c\u53ef\u4ee5\u5728\u201cPython Interpreter\u201d\u8bbe\u7f6e\u4e2d\u8fdb\u884c\u8c03\u6574\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Pycharm\u4f7f\u7528Python\u5e93\u7684\u65b9\u6cd5\u6709\uff1a\u5b89\u88c5\u5e93\u3001\u5bfc\u5165\u5e93\u3001\u4f7f\u7528\u5e93\u3001\u8c03\u8bd5\u4ee3\u7801\u3002\u4e0b\u9762\u6211\u5c06\u8be6\u7ec6\u63cf\u8ff0\u5982\u4f55\u5728Pychar [&hellip;]","protected":false},"author":3,"featured_media":1166761,"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\/1166753"}],"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=1166753"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1166753\/revisions"}],"predecessor-version":[{"id":1166763,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1166753\/revisions\/1166763"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1166761"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1166753"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1166753"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1166753"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}