{"id":1207,"date":"2023-07-27T07:20:18","date_gmt":"2023-07-27T07:20:18","guid":{"rendered":"https:\/\/statorials.org\/cn\/python-%e4%b8%ad%e7%9a%84%e4%b8%bb%e8%a6%81%e7%bb%84%e4%bb%b6%e5%9b%9e%e5%bd%92\/"},"modified":"2023-07-27T07:20:18","modified_gmt":"2023-07-27T07:20:18","slug":"python-%e4%b8%ad%e7%9a%84%e4%b8%bb%e8%a6%81%e7%bb%84%e4%bb%b6%e5%9b%9e%e5%bd%92","status":"publish","type":"post","link":"https:\/\/statorials.org\/cn\/python-%e4%b8%ad%e7%9a%84%e4%b8%bb%e8%a6%81%e7%bb%84%e4%bb%b6%e5%9b%9e%e5%bd%92\/","title":{"rendered":"Python \u4e2d\u7684\u4e3b\u6210\u5206\u56de\u5f52\uff08\u9010\u6b65\uff09"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">\u7ed9\u5b9a\u4e00\u7ec4<em>p<\/em>\u4e2a\u9884\u6d4b\u53d8\u91cf\u548c\u4e00\u4e2a\u54cd\u5e94\u53d8\u91cf\uff0c<a href=\"https:\/\/statorials.org\/cn\/\u591a\u5143\u7ebf\u6027\u56de\u5f52-1\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u591a\u5143\u7ebf\u6027\u56de\u5f52<\/a>\u4f7f\u7528\u6700\u5c0f\u4e8c\u4e58\u6cd5\u6765\u6700\u5c0f\u5316\u6b8b\u5dee\u5e73\u65b9\u548c (RSS)\uff1a<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>RSS = \u03a3(y <sub>i<\/sub> \u2013 \u0177 <sub>i<\/sub> ) <sup>2<\/sup><\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">\u91d1\u5b50\uff1a<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>\u03a3<\/strong> \uff1a\u5e0c\u814a\u7b26\u53f7\uff0c\u610f\u601d\u662f<em>\u548c<\/em><\/span><\/li>\n<li><span style=\"color: #000000;\"><strong>y <sub>i<\/sub><\/strong> \uff1a<sup>\u7b2c i \u4e2a<\/sup>\u89c2\u6d4b\u503c\u7684\u5b9e\u9645\u54cd\u5e94\u503c<\/span><\/li>\n<li><span style=\"color: #000000;\"><strong>\u0177 <sub>i<\/sub><\/strong> \uff1a\u57fa\u4e8e\u591a\u5143\u7ebf\u6027\u56de\u5f52\u6a21\u578b\u7684\u9884\u6d4b\u54cd\u5e94\u503c<\/span><\/li>\n<\/ul>\n<p><span style=\"color: #000000;\">\u7136\u800c\uff0c\u5f53\u9884\u6d4b\u53d8\u91cf\u9ad8\u5ea6\u76f8\u5173\u65f6\uff0c<\/span> <a href=\"https:\/\/statorials.org\/cn\/\u591a\u91cd\u5171\u7ebf\u6027\u56de\u5f52\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u591a\u91cd\u5171\u7ebf\u6027<\/a><span style=\"color: #000000;\">\u53ef\u80fd\u4f1a\u6210\u4e3a\u4e00\u4e2a\u95ee\u9898\u3002\u8fd9\u53ef\u80fd\u4f1a\u4f7f\u6a21\u578b\u7cfb\u6570\u4f30\u8ba1\u4e0d\u53ef\u9760\u5e76\u8868\u73b0\u51fa\u8f83\u9ad8\u7684\u65b9\u5dee\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u907f\u514d\u6b64\u95ee\u9898\u7684\u4e00\u79cd\u65b9\u6cd5\u662f\u4f7f\u7528<a href=\"https:\/\/statorials.org\/cn\/\u4e3b\u6210\u5206\u56de\u5f52\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u4e3b\u6210\u5206\u56de\u5f52<\/a>\uff0c\u5b83\u627e\u5230\u539f\u59cb<em>p<\/em>\u4e2a\u9884\u6d4b\u53d8\u91cf\u7684<em>M \u4e2a<\/em>\u7ebf\u6027\u7ec4\u5408\uff08\u79f0\u4e3a\u201c\u4e3b\u6210\u5206\u201d\uff09\uff0c\u7136\u540e\u4f7f\u7528\u6700\u5c0f\u4e8c\u4e58\u6cd5\u6765\u62df\u5408\u4f7f\u7528\u4e3b\u6210\u5206\u4f5c\u4e3a\u9884\u6d4b\u53d8\u91cf\u7684\u7ebf\u6027\u56de\u5f52\u6a21\u578b\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u672c\u6559\u7a0b\u63d0\u4f9b\u4e86\u5982\u4f55\u5728 Python \u4e2d\u6267\u884c\u4e3b\u6210\u5206\u56de\u5f52\u7684\u5206\u6b65\u793a\u4f8b\u3002<\/span><\/p>\n<h3><span style=\"color: #000000;\"><strong>\u7b2c1\u6b65\uff1a\u5bfc\u5165\u5fc5\u8981\u7684\u5305<\/strong><\/span><\/h3>\n<p><span style=\"color: #000000;\"><span style=\"color: #000000;\">\u9996\u5148\uff0c\u6211\u4eec\u5c06\u5bfc\u5165\u5728 Python \u4e2d\u6267\u884c\u4e3b\u6210\u5206\u56de\u5f52 (PCR) \u6240\u9700\u7684\u5305\uff1a<\/span><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008000;\">import<\/span> numpy <span style=\"color: #008000;\">as<\/span> np\n<span style=\"color: #008000;\">import<\/span> pandas <span style=\"color: #008000;\">as<\/span> pd\n<span style=\"color: #008000;\">import<\/span> matplotlib. <span style=\"color: #3366ff;\">pyplot<\/span> <span style=\"color: #008000;\">as<\/span> plt\n<span style=\"color: #008000;\">from<\/span> sklearn. <span style=\"color: #3366ff;\">preprocessing<\/span> <span style=\"color: #008000;\">import<\/span> scale \n<span style=\"color: #008000;\">from<\/span> sklearn <span style=\"color: #008000;\">import<\/span> model_selection\n<span style=\"color: #008000;\">from<\/span> sklearn. <span style=\"color: #3366ff;\">model_selection<\/span> <span style=\"color: #008000;\">import<\/span> RepeatedKFold\n<span style=\"color: #008000;\">from<\/span> sklearn.model_selection <span style=\"color: #008000;\">import<\/span> train_test_split\n<span style=\"color: #008000;\">from<\/span> sklearn. PCA <span style=\"color: #008000;\">import<\/span> <span style=\"color: #3366ff;\">decomposition<\/span>\n<span style=\"color: #008000;\">from<\/span> sklearn. <span style=\"color: #3366ff;\">linear_model<\/span> <span style=\"color: #008000;\">import<\/span> LinearRegression\n<span style=\"color: #008000;\">from<\/span> sklearn. <span style=\"color: #3366ff;\">metrics<\/span> <span style=\"color: #008000;\">import<\/span> mean_squared_error\n<\/strong><\/span><\/pre>\n<h3><span style=\"color: #000000;\"><strong>\u7b2c2\u6b65\uff1a\u52a0\u8f7d\u6570\u636e<\/strong><\/span><\/h3>\n<p><span style=\"color: #000000;\">\u5728\u6b64\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5c06\u4f7f\u7528\u540d\u4e3a<strong>mtcars<\/strong>\u7684\u6570\u636e\u96c6\uff0c\u5176\u4e2d\u5305\u542b 33 \u8f86\u4e0d\u540c\u6c7d\u8f66\u7684\u4fe1\u606f\u3002\u6211\u4eec\u5c06\u4f7f\u7528<strong>hp<\/strong>\u4f5c\u4e3a\u54cd\u5e94\u53d8\u91cf\uff0c\u5e76\u4f7f\u7528\u4ee5\u4e0b\u53d8\u91cf\u4f5c\u4e3a\u9884\u6d4b\u53d8\u91cf\uff1a<\/span><\/p>\n<ul>\n<li><span style=\"color: #000000;\">\u82f1\u91cc\/\u52a0\u4ed1<\/span><\/li>\n<li><span style=\"color: #000000;\">\u5c55\u793a<\/span><\/li>\n<li><span style=\"color: #000000;\">\u62c9\u5c4e<\/span><\/li>\n<li><span style=\"color: #000000;\">\u91cd\u91cf<\/span><\/li>\n<li><span style=\"color: #000000;\">\u5feb\u79d2<\/span><\/li>\n<\/ul>\n<p><span style=\"color: #000000;\"><span style=\"color: #000000;\">\u4ee5\u4e0b\u4ee3\u7801\u5c55\u793a\u4e86\u5982\u4f55\u52a0\u8f7d\u548c\u663e\u793a\u6b64\u6570\u636e\u96c6\uff1a<\/span><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#define URL where data is located\n<\/span>url = \"https:\/\/raw.githubusercontent.com\/Statorials\/Python-Guides\/main\/mtcars.csv\"\n\n<span style=\"color: #008080;\">#read in data\n<\/span>data_full = pd. <span style=\"color: #3366ff;\">read_csv<\/span> (url)\n\n<span style=\"color: #008080;\">#select subset of data\n<\/span>data = data_full[[\"mpg\", \"disp\", \"drat\", \"wt\", \"qsec\", \"hp\"]]\n\n<span style=\"color: #008080;\">#view first six rows of data\n<\/span>data[0:6]\n\n\n        mpg disp drat wt qsec hp\n0 21.0 160.0 3.90 2.620 16.46 110\n1 21.0 160.0 3.90 2.875 17.02 110\n2 22.8 108.0 3.85 2.320 18.61 93\n3 21.4 258.0 3.08 3.215 19.44 110\n4 18.7 360.0 3.15 3.440 17.02 175\n5 18.1 225.0 2.76 3.460 20.22 105<\/strong><\/span><\/pre>\n<h3><strong>\u6b65\u9aa43\uff1a\u8c03\u6574PCR\u6a21\u578b<\/strong><\/h3>\n<p><span style=\"color: #000000;\">\u4ee5\u4e0b\u4ee3\u7801\u663e\u793a\u4e86\u5982\u4f55\u4f7f PCR \u6a21\u578b\u9002\u5408\u6b64\u6570\u636e\u3002\u8bf7\u6ce8\u610f\u4ee5\u4e0b\u4e8b\u9879\uff1a<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>pca.fit_transform(scale(X))<\/strong> \uff1a\u8fd9\u544a\u8bc9 Python \u6bcf\u4e2a\u9884\u6d4b\u53d8\u91cf\u90fd\u5e94\u8be5\u7f29\u653e\u4e3a\u5747\u503c 0 \u548c\u6807\u51c6\u5dee 1\u3002\u8fd9\u786e\u4fdd\u4e86\u5982\u679c\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\uff0c\u5219\u9884\u6d4b\u53d8\u91cf\u4e0d\u4f1a\u5bf9\u6a21\u578b\u4ea7\u751f\u592a\u5927\u5f71\u54cd\uff1a\u51fa\u73b0\u8fd9\u79cd\u60c5\u51b5\u3002\u4ee5\u4e0d\u540c\u7684\u5355\u4f4d\u6765\u8861\u91cf\u3002<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>cv = RepeatedKFold()<\/strong> \uff1a\u8fd9\u544a\u8bc9 Python \u4f7f\u7528<a href=\"https:\/\/statorials.org\/cn\/k\u6298\u4ea4\u53c9\u9a8c\u8bc1\/\" target=\"_blank\" rel=\"noopener noreferrer\">k \u6298\u4ea4\u53c9\u9a8c\u8bc1<\/a>\u6765\u8bc4\u4f30\u6a21\u578b\u6027\u80fd\u3002\u5bf9\u4e8e\u672c\u4f8b\uff0c\u6211\u4eec\u9009\u62e9 k = 10 \u6b21\uff0c\u91cd\u590d 3 \u6b21\u3002<\/span> <\/li>\n<\/ul>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#define predictor and response variables\n<\/span>X = data[[\"mpg\", \"disp\", \"drat\", \"wt\", \"qsec\"]]\ny = data[[\"hp\"]]\n\n<span style=\"color: #008080;\">#scale predictor variables\n<\/span>pca = pca()\nX_reduced = pca. <span style=\"color: #3366ff;\">fit_transform<\/span> ( <span style=\"color: #3366ff;\">scale<\/span> (X))\n\n<span style=\"color: #008080;\">#define cross validation method\n<\/span>cv = RepeatedKFold(n_splits= <span style=\"color: #008000;\">10<\/span> , n_repeats= <span style=\"color: #008000;\">3<\/span> , random_state= <span style=\"color: #008000;\">1<\/span> )\n\nregr = LinearRegression()\nmse = []\n\n<span style=\"color: #008080;\"># Calculate MSE with only the intercept\n<\/span>score = -1*model_selection. <span style=\"color: #3366ff;\">cross_val_score<\/span> (regr,\n           n.p. <span style=\"color: #3366ff;\">ones<\/span> ((len(X_reduced),1)), y, cv=cv,\n           scoring=' <span style=\"color: #008000;\">neg_mean_squared_error<\/span> '). <span style=\"color: #3366ff;\">mean<\/span> ()    \nmse. <span style=\"color: #3366ff;\">append<\/span> (score)\n\n<span style=\"color: #008080;\"># Calculate MSE using cross-validation, adding one component at a time\n<\/span><span style=\"color: #008000;\">for<\/span> i <span style=\"color: #008000;\">in<\/span> np. <span style=\"color: #3366ff;\">arange<\/span> (1, 6):\n    score = -1*model_selection. <span style=\"color: #3366ff;\">cross_val_score<\/span> (regr,\n               X_reduced[:,:i], y, cv=cv, scoring=' <span style=\"color: #008000;\">neg_mean_squared_error<\/span> '). <span style=\"color: #3366ff;\">mean<\/span> ()\n    mse. <span style=\"color: #3366ff;\">append<\/span> (score)\n    \n<span style=\"color: #008080;\"># Plot cross-validation results    \n<\/span>plt. <span style=\"color: #3366ff;\">plot<\/span> (mse)\nplt. <span style=\"color: #3366ff;\">xlabel<\/span> ('Number of Principal Components')\nplt. <span style=\"color: #3366ff;\">ylabel<\/span> ('MSE')\nplt. <span style=\"color: #3366ff;\">title<\/span> ('hp')<\/strong><\/span> <\/pre>\n<h3><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-11950 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/pcrpython1.png\" alt=\"Python \u4e2d\u7684\u4e3b\u6210\u5206\u56de\u5f52\" width=\"424\" height=\"285\" srcset=\"\" sizes=\"auto, \"><\/h3>\n<p><span style=\"color: #000000;\">\u8be5\u56fe\u6cbf x \u8f74\u663e\u793a\u4e3b\u6210\u5206\u6570\u91cf\uff0c\u6cbf y \u8f74\u663e\u793a MSE\uff08\u5747\u65b9\u8bef\u5dee\uff09\u68c0\u9a8c\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u4ece\u56fe\u4e2d\u6211\u4eec\u53ef\u4ee5\u770b\u5230\uff0c\u901a\u8fc7\u6dfb\u52a0\u4e24\u4e2a\u4e3b\u6210\u5206\uff0c\u68c0\u9a8c\u7684 MSE \u4f1a\u4e0b\u964d\uff0c\u4f46\u5f53\u6dfb\u52a0\u4e24\u4e2a\u4ee5\u4e0a\u4e3b\u6210\u5206\u65f6\uff0cMSE \u5c31\u4f1a\u5f00\u59cb\u589e\u52a0\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u56e0\u6b64\uff0c\u6700\u4f18\u6a21\u578b\u4ec5\u5305\u542b\u524d\u4e24\u4e2a\u4e3b\u6210\u5206\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u6211\u4eec\u8fd8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u6765\u8ba1\u7b97\u901a\u8fc7\u5c06\u6bcf\u4e2a\u4e3b\u6210\u5206\u6dfb\u52a0\u5230\u6a21\u578b\u4e2d\u6765\u89e3\u91ca\u7684\u54cd\u5e94\u53d8\u91cf\u7684\u65b9\u5dee\u767e\u5206\u6bd4\uff1a<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong>n.p. <span style=\"color: #3366ff;\">cumsum<\/span> (np. <span style=\"color: #3366ff;\">round<\/span> (pca. <span style=\"color: #3366ff;\">explained_variance_ratio_<\/span> , decimals= <span style=\"color: #008000;\">4<\/span> )* <span style=\"color: #008000;\">100<\/span> )\n\narray([69.83, 89.35, 95.88, 98.95, 99.99])\n<\/strong><\/span><\/pre>\n<p><span style=\"color: #000000;\">\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/span><\/p>\n<ul>\n<li><span style=\"color: #000000;\">\u4ec5\u4f7f\u7528\u7b2c\u4e00\u4e2a\u4e3b\u6210\u5206\uff0c\u6211\u4eec\u53ef\u4ee5\u89e3\u91ca\u54cd\u5e94\u53d8\u91cf\u4e2d<strong>69.83%<\/strong>\u7684\u53d8\u5f02\u3002<\/span><\/li>\n<li><span style=\"color: #000000;\">\u901a\u8fc7\u6dfb\u52a0\u7b2c\u4e8c\u4e2a\u4e3b\u6210\u5206\uff0c\u6211\u4eec\u53ef\u4ee5\u89e3\u91ca\u54cd\u5e94\u53d8\u91cf\u4e2d<strong>89.35%<\/strong>\u7684\u53d8\u5f02\u3002<\/span><\/li>\n<\/ul>\n<p><span style=\"color: #000000;\">\u8bf7\u6ce8\u610f\uff0c\u6211\u4eec\u4ecd\u7136\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u66f4\u591a\u7684\u4e3b\u6210\u5206\u6765\u89e3\u91ca\u66f4\u591a\u7684\u65b9\u5dee\uff0c\u4f46\u662f\u6211\u4eec\u53ef\u4ee5\u770b\u5230\uff0c\u6dfb\u52a0\u4e24\u4e2a\u4ee5\u4e0a\u7684\u4e3b\u6210\u5206\u5b9e\u9645\u4e0a\u5e76\u4e0d\u4f1a\u589e\u52a0\u89e3\u91ca\u65b9\u5dee\u7684\u767e\u5206\u6bd4\u592a\u591a\u3002<\/span><\/p>\n<h3><span style=\"color: #000000;\"><strong>\u7b2c 4 \u6b65\uff1a\u4f7f\u7528\u6700\u7ec8\u6a21\u578b\u8fdb\u884c\u9884\u6d4b<\/strong><\/span><\/h3>\n<p><span style=\"color: #000000;\">\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u6700\u7ec8\u7684\u53cc\u4e3b\u6210\u5206 PCR \u6a21\u578b\u6765\u5bf9\u65b0\u89c2\u5bdf\u7ed3\u679c\u8fdb\u884c\u9884\u6d4b\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u4ee5\u4e0b\u4ee3\u7801\u5c55\u793a\u4e86\u5982\u4f55\u5c06\u539f\u59cb\u6570\u636e\u96c6\u62c6\u5206\u4e3a\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6\uff0c\u5e76\u4f7f\u7528\u5177\u6709\u4e24\u4e2a\u4e3b\u6210\u5206\u7684 PCR \u6a21\u578b\u5bf9\u6d4b\u8bd5\u96c6\u8fdb\u884c\u9884\u6d4b\u3002<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#split the dataset into training (70%) and testing (30%) sets\n<\/span>X_train,X_test,y_train,y_test = <span style=\"color: #3366ff;\">train_test_split<\/span> (X,y,test_size= <span style=\"color: #008000;\">0.3<\/span> , random_state= <span style=\"color: #008000;\">0<\/span> ) \n\n<span style=\"color: #008080;\">#scale the training and testing data\n<\/span>X_reduced_train = pca. <span style=\"color: #3366ff;\">fit_transform<\/span> ( <span style=\"color: #3366ff;\">scale<\/span> (X_train))\nX_reduced_test = pca. <span style=\"color: #3366ff;\">transform<\/span> ( <span style=\"color: #3366ff;\">scale<\/span> (X_test))[:,:1]\n\n<span style=\"color: #008080;\">#train PCR model on training data \n<\/span>regr = LinearRegression()\nreg. <span style=\"color: #3366ff;\">fit<\/span> (X_reduced_train[:,:1], y_train)\n\n<span style=\"color: #008080;\">#calculate RMSE\n<\/span>pred = regr. <span style=\"color: #3366ff;\">predict<\/span> (X_reduced_test)\nn.p. <span style=\"color: #3366ff;\">sqrt<\/span> ( <span style=\"color: #3366ff;\">mean_squared_error<\/span> (y_test, pred))\n\n40.2096\n<\/strong><\/span><\/pre>\n<p><span style=\"color: #000000;\">\u6211\u4eec\u770b\u5230 RMSE \u6d4b\u8bd5\u7ed3\u679c\u4e3a<strong>40.2096<\/strong> \u3002\u8fd9\u662f\u6d4b\u8bd5\u96c6\u89c2\u6d4b\u503c\u7684\u9884\u6d4b<em>hp<\/em>\u503c\u548c\u89c2\u5bdf\u5230\u7684<em>hp<\/em>\u503c\u4e4b\u95f4\u7684\u5e73\u5747\u504f\u5dee\u3002<\/span><\/p>\n<p><span style=\"color: #000000;\">\u6b64\u793a\u4f8b\u4e2d\u4f7f\u7528\u7684\u5b8c\u6574 Python \u4ee3\u7801\u53ef\u4ee5<a href=\"https:\/\/github.com\/Statorials\/Python-Guides\/blob\/main\/principal_components_regression.py\" target=\"_blank\" rel=\"noopener noreferrer\">\u5728\u6b64\u5904<\/a>\u627e\u5230\u3002<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7ed9\u5b9a\u4e00\u7ec4p\u4e2a\u9884\u6d4b\u53d8\u91cf\u548c\u4e00\u4e2a\u54cd\u5e94\u53d8\u91cf\uff0c\u591a\u5143\u7ebf\u6027\u56de\u5f52\u4f7f\u7528\u6700\u5c0f\u4e8c\u4e58\u6cd5\u6765\u6700\u5c0f\u5316\u6b8b\u5dee\u5e73\u65b9\u548c (RSS)\uff1a RSS = \u03a3 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-1207","post","type-post","status-publish","format-standard","hentry","category-11"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python \u4e2d\u7684\u4e3b\u6210\u5206\u56de\u5f52\uff08\u9010\u6b65\uff09<\/title>\n<meta name=\"description\" content=\"\u672c\u6559\u7a0b\u4ecb\u7ecd\u5982\u4f55\u5728 Python \u4e2d\u6267\u884c\u4e3b\u6210\u5206\u56de\u5f52\uff0c\u5305\u62ec\u5206\u6b65\u793a\u4f8b\u3002\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/statorials.org\/cn\/python-\u4e2d\u7684\u4e3b\u8981\u7ec4\u4ef6\u56de\u5f52\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python \u4e2d\u7684\u4e3b\u6210\u5206\u56de\u5f52\uff08\u9010\u6b65\uff09\" \/>\n<meta property=\"og:description\" content=\"\u672c\u6559\u7a0b\u4ecb\u7ecd\u5982\u4f55\u5728 Python \u4e2d\u6267\u884c\u4e3b\u6210\u5206\u56de\u5f52\uff0c\u5305\u62ec\u5206\u6b65\u793a\u4f8b\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/cn\/python-\u4e2d\u7684\u4e3b\u8981\u7ec4\u4ef6\u56de\u5f52\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-27T07:20:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/pcrpython1.png\" \/>\n<meta name=\"author\" content=\"\u672c\u6770\u660e\u00b7\u5b89\u5fb7\u68ee\u535a\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u672c\u6770\u660e\u00b7\u5b89\u5fb7\u68ee\u535a\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/cn\/python-%e4%b8%ad%e7%9a%84%e4%b8%bb%e8%a6%81%e7%bb%84%e4%bb%b6%e5%9b%9e%e5%bd%92\/\",\"url\":\"https:\/\/statorials.org\/cn\/python-%e4%b8%ad%e7%9a%84%e4%b8%bb%e8%a6%81%e7%bb%84%e4%bb%b6%e5%9b%9e%e5%bd%92\/\",\"name\":\"Python \u4e2d\u7684\u4e3b\u6210\u5206\u56de\u5f52\uff08\u9010\u6b65\uff09\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/cn\/#website\"},\"datePublished\":\"2023-07-27T07:20:18+00:00\",\"dateModified\":\"2023-07-27T07:20:18+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/cn\/#\/schema\/person\/124e4e5b7c9f8dc0f1f95cc8c1db3261\"},\"description\":\"\u672c\u6559\u7a0b\u4ecb\u7ecd\u5982\u4f55\u5728 Python \u4e2d\u6267\u884c\u4e3b\u6210\u5206\u56de\u5f52\uff0c\u5305\u62ec\u5206\u6b65\u793a\u4f8b\u3002\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/cn\/python-%e4%b8%ad%e7%9a%84%e4%b8%bb%e8%a6%81%e7%bb%84%e4%bb%b6%e5%9b%9e%e5%bd%92\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/cn\/python-%e4%b8%ad%e7%9a%84%e4%b8%bb%e8%a6%81%e7%bb%84%e4%bb%b6%e5%9b%9e%e5%bd%92\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/cn\/python-%e4%b8%ad%e7%9a%84%e4%b8%bb%e8%a6%81%e7%bb%84%e4%bb%b6%e5%9b%9e%e5%bd%92\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u5bb6\",\"item\":\"https:\/\/statorials.org\/cn\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python \u4e2d\u7684\u4e3b\u6210\u5206\u56de\u5f52\uff08\u9010\u6b65\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/cn\/#website\",\"url\":\"https:\/\/statorials.org\/cn\/\",\"name\":\"Statorials\",\"description\":\"\u60a8\u7684\u7edf\u8ba1\u7d20\u517b\u6307\u5357\uff01\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/cn\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/cn\/#\/schema\/person\/124e4e5b7c9f8dc0f1f95cc8c1db3261\",\"name\":\"\u672c\u6770\u660e\u00b7\u5b89\u5fb7\u68ee\u535a\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/statorials.org\/cn\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/cn\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/cn\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"\u672c\u6770\u660e\u00b7\u5b89\u5fb7\u68ee\u535a\"},\"description\":\"\u5927\u5bb6\u597d\uff0c\u6211\u662f\u672c\u6770\u660e\uff0c\u4e00\u4f4d\u9000\u4f11\u7684\u7edf\u8ba1\u5b66\u6559\u6388\uff0c\u540e\u6765\u6210\u4e3a Statorials \u7684\u70ed\u5fc3\u6559\u5e08\u3002 \u51ed\u501f\u5728\u7edf\u8ba1\u9886\u57df\u7684\u4e30\u5bcc\u7ecf\u9a8c\u548c\u4e13\u4e1a\u77e5\u8bc6\uff0c\u6211\u6e34\u671b\u5206\u4eab\u6211\u7684\u77e5\u8bc6\uff0c\u901a\u8fc7 Statorials \u589e\u5f3a\u5b66\u751f\u7684\u80fd\u529b\u3002\u4e86\u89e3\u66f4\u591a\",\"sameAs\":[\"https:\/\/statorials.org\/cn\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python \u4e2d\u7684\u4e3b\u6210\u5206\u56de\u5f52\uff08\u9010\u6b65\uff09","description":"\u672c\u6559\u7a0b\u4ecb\u7ecd\u5982\u4f55\u5728 Python \u4e2d\u6267\u884c\u4e3b\u6210\u5206\u56de\u5f52\uff0c\u5305\u62ec\u5206\u6b65\u793a\u4f8b\u3002","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/statorials.org\/cn\/python-\u4e2d\u7684\u4e3b\u8981\u7ec4\u4ef6\u56de\u5f52\/","og_locale":"zh_CN","og_type":"article","og_title":"Python \u4e2d\u7684\u4e3b\u6210\u5206\u56de\u5f52\uff08\u9010\u6b65\uff09","og_description":"\u672c\u6559\u7a0b\u4ecb\u7ecd\u5982\u4f55\u5728 Python \u4e2d\u6267\u884c\u4e3b\u6210\u5206\u56de\u5f52\uff0c\u5305\u62ec\u5206\u6b65\u793a\u4f8b\u3002","og_url":"https:\/\/statorials.org\/cn\/python-\u4e2d\u7684\u4e3b\u8981\u7ec4\u4ef6\u56de\u5f52\/","og_site_name":"Statorials","article_published_time":"2023-07-27T07:20:18+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/pcrpython1.png"}],"author":"\u672c\u6770\u660e\u00b7\u5b89\u5fb7\u68ee\u535a","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u672c\u6770\u660e\u00b7\u5b89\u5fb7\u68ee\u535a","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/cn\/python-%e4%b8%ad%e7%9a%84%e4%b8%bb%e8%a6%81%e7%bb%84%e4%bb%b6%e5%9b%9e%e5%bd%92\/","url":"https:\/\/statorials.org\/cn\/python-%e4%b8%ad%e7%9a%84%e4%b8%bb%e8%a6%81%e7%bb%84%e4%bb%b6%e5%9b%9e%e5%bd%92\/","name":"Python \u4e2d\u7684\u4e3b\u6210\u5206\u56de\u5f52\uff08\u9010\u6b65\uff09","isPartOf":{"@id":"https:\/\/statorials.org\/cn\/#website"},"datePublished":"2023-07-27T07:20:18+00:00","dateModified":"2023-07-27T07:20:18+00:00","author":{"@id":"https:\/\/statorials.org\/cn\/#\/schema\/person\/124e4e5b7c9f8dc0f1f95cc8c1db3261"},"description":"\u672c\u6559\u7a0b\u4ecb\u7ecd\u5982\u4f55\u5728 Python \u4e2d\u6267\u884c\u4e3b\u6210\u5206\u56de\u5f52\uff0c\u5305\u62ec\u5206\u6b65\u793a\u4f8b\u3002","breadcrumb":{"@id":"https:\/\/statorials.org\/cn\/python-%e4%b8%ad%e7%9a%84%e4%b8%bb%e8%a6%81%e7%bb%84%e4%bb%b6%e5%9b%9e%e5%bd%92\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/cn\/python-%e4%b8%ad%e7%9a%84%e4%b8%bb%e8%a6%81%e7%bb%84%e4%bb%b6%e5%9b%9e%e5%bd%92\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/cn\/python-%e4%b8%ad%e7%9a%84%e4%b8%bb%e8%a6%81%e7%bb%84%e4%bb%b6%e5%9b%9e%e5%bd%92\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u5bb6","item":"https:\/\/statorials.org\/cn\/"},{"@type":"ListItem","position":2,"name":"Python \u4e2d\u7684\u4e3b\u6210\u5206\u56de\u5f52\uff08\u9010\u6b65\uff09"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/cn\/#website","url":"https:\/\/statorials.org\/cn\/","name":"Statorials","description":"\u60a8\u7684\u7edf\u8ba1\u7d20\u517b\u6307\u5357\uff01","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/cn\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/statorials.org\/cn\/#\/schema\/person\/124e4e5b7c9f8dc0f1f95cc8c1db3261","name":"\u672c\u6770\u660e\u00b7\u5b89\u5fb7\u68ee\u535a","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/statorials.org\/cn\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/cn\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/cn\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"\u672c\u6770\u660e\u00b7\u5b89\u5fb7\u68ee\u535a"},"description":"\u5927\u5bb6\u597d\uff0c\u6211\u662f\u672c\u6770\u660e\uff0c\u4e00\u4f4d\u9000\u4f11\u7684\u7edf\u8ba1\u5b66\u6559\u6388\uff0c\u540e\u6765\u6210\u4e3a Statorials \u7684\u70ed\u5fc3\u6559\u5e08\u3002 \u51ed\u501f\u5728\u7edf\u8ba1\u9886\u57df\u7684\u4e30\u5bcc\u7ecf\u9a8c\u548c\u4e13\u4e1a\u77e5\u8bc6\uff0c\u6211\u6e34\u671b\u5206\u4eab\u6211\u7684\u77e5\u8bc6\uff0c\u901a\u8fc7 Statorials \u589e\u5f3a\u5b66\u751f\u7684\u80fd\u529b\u3002\u4e86\u89e3\u66f4\u591a","sameAs":["https:\/\/statorials.org\/cn"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/cn\/wp-json\/wp\/v2\/posts\/1207","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/statorials.org\/cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/cn\/wp-json\/wp\/v2\/comments?post=1207"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/cn\/wp-json\/wp\/v2\/posts\/1207\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/cn\/wp-json\/wp\/v2\/media?parent=1207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/cn\/wp-json\/wp\/v2\/categories?post=1207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/cn\/wp-json\/wp\/v2\/tags?post=1207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}