{"id":56986,"date":"2025-08-15T06:19:44","date_gmt":"2025-08-14T22:19:44","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/56986.html"},"modified":"2025-08-15T06:19:44","modified_gmt":"2025-08-14T22:19:44","slug":"%e7%bc%96%e7%a8%8b%e4%b8%8e%e6%95%b0%e5%ad%a6-02-017-python-%e9%9d%a2%e5%90%91%e5%af%b9%e8%b1%a1%e7%bc%96%e7%a8%8b-03%e8%af%be%e9%a2%98%e3%80%81%e5%b1%9e%e6%80%a7%e5%92%8c%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/56986.html","title":{"rendered":"\u7f16\u7a0b\u4e0e\u6570\u5b66 02-017 Python \u9762\u5411\u5bf9\u8c61\u7f16\u7a0b 03\u8bfe\u9898\u3001\u5c5e\u6027\u548c\u65b9\u6cd5"},"content":{"rendered":"<\/p>\n<h4>\u7f16\u7a0b\u4e0e\u6570\u5b66 02-017 Python \u9762\u5411\u5bf9\u8c61\u7f16\u7a0b 03\u8bfe\u9898\u3001\u5c5e\u6027\u548c\u65b9\u6cd5<\/h4>\n<ul>\n<li>\u4e00\u3001\u5c5e\u6027&#xff08;Attributes&#xff09;<\/li>\n<li>\n<ul>\n<li>\n<ul>\n<li>\u5b9a\u4e49<\/li>\n<li>(1) \u5b9e\u4f8b\u5c5e\u6027<\/li>\n<li>(2) \u7c7b\u5c5e\u6027<\/li>\n<li>(3) \u52a8\u6001\u6dfb\u52a0\u5c5e\u6027<\/li>\n<li>(4) \u5c5e\u6027\u8bbf\u95ee\u63a7\u5236<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u4e8c\u3001\u65b9\u6cd5&#xff08;Methods&#xff09;<\/li>\n<li>\n<ul>\n<li>\n<ul>\n<li>\u5b9a\u4e49<\/li>\n<li>(1) \u5b9e\u4f8b\u65b9\u6cd5<\/li>\n<li>(2) \u7c7b\u65b9\u6cd5&#xff08;&#096;&#064;classmethod&#096;&#xff09;<\/li>\n<li>(3) \u9759\u6001\u65b9\u6cd5&#xff08;&#096;&#064;staticmethod&#096;&#xff09;<\/li>\n<li>\u5bf9\u6bd4\u603b\u7ed3<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u4e09\u3001\u7279\u6b8a\u65b9\u6cd5&#xff08;\u9b54\u672f\u65b9\u6cd5&#xff09;<\/li>\n<li>\n<ul>\n<li>\n<ul>\n<li>(1) \u5e38\u7528\u9b54\u672f\u65b9\u6cd5<\/li>\n<li>(2) \u793a\u4f8b<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u56db\u3001\u5c5e\u6027\u88c5\u9970\u5668&#xff08;&#096;&#064;property&#096;&#xff09;<\/li>\n<li>\n<ul>\n<li>\n<ul>\n<li>(1) \u57fa\u672c\u7528\u6cd5<\/li>\n<li>(2) \u7528\u9014<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u4e94\u3001\u6982\u5ff5\u603b\u7ed3<\/li>\n<li>\u516d\u3001\u5e94\u7528\u573a\u666f<\/li>\n<li>\u5168\u6587\u603b\u7ed3<\/li>\n<\/ul>\n<p>\u6458\u8981&#xff1a;\u672c\u6587\u7cfb\u7edf\u8bb2\u89e3Python\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u4e2d\u7684\u5c5e\u6027\u4e0e\u65b9\u6cd5&#xff1a;\u533a\u5206\u5b9e\u4f8b\u5c5e\u6027\u4e0e\u7c7b\u5c5e\u6027&#xff0c;\u4ecb\u7ecd\u5b9e\u4f8b\u3001\u7c7b\u3001\u9759\u6001\u65b9\u6cd5\u53ca\u9b54\u672f\u65b9\u6cd5&#xff0c;\u5c55\u793a&#064;property\u5b9e\u73b0\u5c5e\u6027\u63a7\u5236\u4e0e\u6570\u636e\u9a8c\u8bc1&#xff0c;\u5e76\u7ed9\u51fa\u5178\u578b\u5e94\u7528\u573a\u666f&#xff0c;\u5e2e\u52a9\u5f00\u53d1\u8005\u6784\u5efa\u9ad8\u5185\u805a\u4f4e\u8026\u5408\u7684\u4ee3\u7801\u3002<\/p>\n<p>\u5173\u952e\u8bcd&#xff1a;Python\u3001\u9762\u5411\u5bf9\u8c61\u3001\u5b9e\u4f8b\u5c5e\u6027\u3001\u7c7b\u5c5e\u6027\u3001\u5b9e\u4f8b\u65b9\u6cd5\u3001\u7c7b\u65b9\u6cd5\u3001\u9759\u6001\u65b9\u6cd5\u3001\u9b54\u672f\u65b9\u6cd5\u3001&#064;property\u3001\u6570\u636e\u9a8c\u8bc1<\/p>\n<p>\u4eba\u5de5\u667a\u80fd\u52a9\u624b&#xff1a;Kimi<\/p>\n<hr \/>\n<h2>\u4e00\u3001\u5c5e\u6027&#xff08;Attributes&#xff09;<\/h2>\n<h4>\u5b9a\u4e49<\/h4>\n<p>\u5c5e\u6027\u662f\u5b58\u50a8\u5728\u5bf9\u8c61\u6216\u7c7b\u4e2d\u7684\u6570\u636e&#xff0c;\u8868\u793a\u5bf9\u8c61\u7684\u72b6\u6001\u3002\u5206\u4e3a&#xff1a;<\/p>\n<ul>\n<li>\u5b9e\u4f8b\u5c5e\u6027&#xff1a;\u5c5e\u4e8e\u7279\u5b9a\u5bf9\u8c61\u3002<\/li>\n<li>\u7c7b\u5c5e\u6027&#xff1a;\u5c5e\u4e8e\u7c7b\u672c\u8eab&#xff0c;\u6240\u6709\u5b9e\u4f8b\u5171\u4eab\u3002<\/li>\n<\/ul>\n<h4>(1) \u5b9e\u4f8b\u5c5e\u6027<\/h4>\n<p>\u901a\u8fc7 self \u5728 __init__ \u65b9\u6cd5\u4e2d\u521d\u59cb\u5316&#xff0c;\u6bcf\u4e2a\u5bf9\u8c61\u72ec\u4eab\u4e00\u4efd\u3002<\/p>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">Dog<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token keyword\">def<\/span> <span class=\"token function\">__init__<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">,<\/span> name<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>name <span class=\"token operator\">&#061;<\/span> name  <span class=\"token comment\"># \u5b9e\u4f8b\u5c5e\u6027<\/span><\/p>\n<p>dog1 <span class=\"token operator\">&#061;<\/span> Dog<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Buddy&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\ndog2 <span class=\"token operator\">&#061;<\/span> Dog<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Max&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>dog1<span class=\"token punctuation\">.<\/span>name<span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u8f93\u51fa: Buddy<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>dog2<span class=\"token punctuation\">.<\/span>name<span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u8f93\u51fa: Max (\u5b9e\u4f8b\u5c5e\u6027\u4e92\u4e0d\u5f71\u54cd)<\/span><\/p>\n<h4>(2) \u7c7b\u5c5e\u6027<\/h4>\n<p>\u5728\u7c7b\u5185\u90e8\u76f4\u63a5\u5b9a\u4e49&#xff0c;\u6240\u6709\u5b9e\u4f8b\u5171\u4eab\u3002<\/p>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">Dog<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    species <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;Canis familiaris&#034;<\/span>  <span class=\"token comment\"># \u7c7b\u5c5e\u6027<\/span><\/p>\n<p>    <span class=\"token keyword\">def<\/span> <span class=\"token function\">__init__<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">,<\/span> name<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>name <span class=\"token operator\">&#061;<\/span> name<\/p>\n<p>dog1 <span class=\"token operator\">&#061;<\/span> Dog<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Buddy&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\ndog2 <span class=\"token operator\">&#061;<\/span> Dog<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Max&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>dog1<span class=\"token punctuation\">.<\/span>species<span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u8f93\u51fa: Canis familiaris<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>dog2<span class=\"token punctuation\">.<\/span>species<span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u8f93\u51fa: Canis familiaris (\u5171\u4eab\u7c7b\u5c5e\u6027)<\/span><\/p>\n<h4>(3) \u52a8\u6001\u6dfb\u52a0\u5c5e\u6027<\/h4>\n<p>Python \u5141\u8bb8\u5728\u8fd0\u884c\u65f6\u52a8\u6001\u6dfb\u52a0\u5c5e\u6027\u3002<\/p>\n<p>dog1<span class=\"token punctuation\">.<\/span>age <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">3<\/span>  <span class=\"token comment\"># \u52a8\u6001\u6dfb\u52a0\u5b9e\u4f8b\u5c5e\u6027<\/span><br \/>\nDog<span class=\"token punctuation\">.<\/span>color <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;brown&#034;<\/span>  <span class=\"token comment\"># \u52a8\u6001\u6dfb\u52a0\u7c7b\u5c5e\u6027<\/span><\/p>\n<h4>(4) \u5c5e\u6027\u8bbf\u95ee\u63a7\u5236<\/h4>\n<ul>\n<li>\u516c\u6709\u5c5e\u6027&#xff1a;\u76f4\u63a5\u8bbf\u95ee&#xff08;\u5982 obj.attr&#xff09;\u3002<\/li>\n<li>\u201c\u79c1\u6709\u201d\u5c5e\u6027&#xff1a;\u7ea6\u5b9a\u7528 _ \u6216 __ \u524d\u7f00&#xff08;\u975e\u5f3a\u5236&#xff09;\u3002<\/li>\n<\/ul>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">MyClass<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token keyword\">def<\/span> <span class=\"token function\">__init__<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>_protected <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">123<\/span>     <span class=\"token comment\"># \u63d0\u793a\u53d7\u4fdd\u62a4&#xff08;\u7ea6\u5b9a&#xff09;<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>__private <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">456<\/span>      <span class=\"token comment\"># \u540d\u79f0\u4fee\u9970&#xff08;\u5b9e\u9645\u53d8\u4e3a _MyClass__private&#xff09;<\/span><\/p>\n<p>obj <span class=\"token operator\">&#061;<\/span> MyClass<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>obj<span class=\"token punctuation\">.<\/span>_protected<span class=\"token punctuation\">)<\/span>            <span class=\"token comment\"># \u53ef\u4ee5\u8bbf\u95ee&#xff08;\u4f46\u7ea6\u5b9a\u4e0d\u63a8\u8350&#xff09;<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>obj<span class=\"token punctuation\">.<\/span>__private<span class=\"token punctuation\">)<\/span>             <span class=\"token comment\"># \u62a5\u9519&#xff01;\u5b9e\u9645\u9700\u8bbf\u95ee obj._MyClass__private<\/span><\/p>\n<hr \/>\n<h2>\u4e8c\u3001\u65b9\u6cd5&#xff08;Methods&#xff09;<\/h2>\n<h4>\u5b9a\u4e49<\/h4>\n<p>\u65b9\u6cd5\u662f\u5b9a\u4e49\u5728\u7c7b\u4e2d\u7684\u51fd\u6570&#xff0c;\u7528\u4e8e\u63cf\u8ff0\u5bf9\u8c61\u7684\u884c\u4e3a\u3002\u5206\u4e3a&#xff1a;<\/p>\n<ul>\n<li>\u5b9e\u4f8b\u65b9\u6cd5&#xff1a;\u64cd\u4f5c\u5b9e\u4f8b\u6570\u636e\u3002<\/li>\n<li>\u7c7b\u65b9\u6cd5&#xff1a;\u64cd\u4f5c\u7c7b\u5c5e\u6027\u3002<\/li>\n<li>\u9759\u6001\u65b9\u6cd5&#xff1a;\u4e0e\u7c7b\u65e0\u5173\u7684\u5de5\u5177\u51fd\u6570\u3002<\/li>\n<\/ul>\n<h4>(1) \u5b9e\u4f8b\u65b9\u6cd5<\/h4>\n<p>\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e3a self&#xff0c;\u6307\u5411\u8c03\u7528\u8be5\u65b9\u6cd5\u7684\u5b9e\u4f8b\u3002<\/p>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">Dog<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token keyword\">def<\/span> <span class=\"token function\">__init__<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">,<\/span> name<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>name <span class=\"token operator\">&#061;<\/span> name<\/p>\n<p>    <span class=\"token keyword\">def<\/span> <span class=\"token function\">bark<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span>  <span class=\"token comment\"># \u5b9e\u4f8b\u65b9\u6cd5<\/span><br \/>\n        <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-interpolation\"><span class=\"token string\">f&#034;<\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>self<span class=\"token punctuation\">.<\/span>name<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\"> says woof!&#034;<\/span><\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>dog <span class=\"token operator\">&#061;<\/span> Dog<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Buddy&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\ndog<span class=\"token punctuation\">.<\/span>bark<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u8f93\u51fa: Buddy says woof!<\/span><\/p>\n<h4>(2) \u7c7b\u65b9\u6cd5&#xff08;&#064;classmethod&#xff09;<\/h4>\n<ul>\n<li>\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e3a cls&#xff0c;\u6307\u5411\u7c7b\u672c\u8eab\u3002<\/li>\n<li>\u7528\u4e8e\u4fee\u6539\u7c7b\u72b6\u6001\u6216\u521b\u5efa\u5de5\u5382\u65b9\u6cd5\u3002<\/li>\n<\/ul>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">Dog<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    species <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;Canis familiaris&#034;<\/span><\/p>\n<p>    <span class=\"token decorator annotation punctuation\">&#064;classmethod<\/span><br \/>\n    <span class=\"token keyword\">def<\/span> <span class=\"token function\">get_species<\/span><span class=\"token punctuation\">(<\/span>cls<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> cls<span class=\"token punctuation\">.<\/span>species<\/p>\n<p><span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>Dog<span class=\"token punctuation\">.<\/span>get_species<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u8f93\u51fa: Canis familiaris<\/span><\/p>\n<h4>(3) \u9759\u6001\u65b9\u6cd5&#xff08;&#064;staticmethod&#xff09;<\/h4>\n<p>\u65e0 self \u6216 cls \u53c2\u6570&#xff0c;\u4ec5\u662f\u7c7b\u7684\u5de5\u5177\u51fd\u6570\u3002<\/p>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">Math<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token decorator annotation punctuation\">&#064;staticmethod<\/span><br \/>\n    <span class=\"token keyword\">def<\/span> <span class=\"token function\">add<\/span><span class=\"token punctuation\">(<\/span>a<span class=\"token punctuation\">,<\/span> b<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> a <span class=\"token operator\">&#043;<\/span> b<\/p>\n<p><span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>Math<span class=\"token punctuation\">.<\/span>add<span class=\"token punctuation\">(<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">3<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u8f93\u51fa: 5<\/span><\/p>\n<h4>\u5bf9\u6bd4\u603b\u7ed3<\/h4>\n<table>\n<tr>\u65b9\u6cd5\u7c7b\u578b\u88c5\u9970\u5668\u7b2c\u4e00\u4e2a\u53c2\u6570\u7528\u9014<\/tr>\n<tbody>\n<tr>\n<td>\u5b9e\u4f8b\u65b9\u6cd5<\/td>\n<td>\u65e0<\/td>\n<td>self<\/td>\n<td>\u64cd\u4f5c\u5b9e\u4f8b\u6570\u636e<\/td>\n<\/tr>\n<tr>\n<td>\u7c7b\u65b9\u6cd5<\/td>\n<td>&#064;classmethod<\/td>\n<td>cls<\/td>\n<td>\u64cd\u4f5c\u7c7b\u5c5e\u6027\u6216\u5de5\u5382\u65b9\u6cd5<\/td>\n<\/tr>\n<tr>\n<td>\u9759\u6001\u65b9\u6cd5<\/td>\n<td>&#064;staticmethod<\/td>\n<td>\u65e0<\/td>\n<td>\u72ec\u7acb\u5de5\u5177\u51fd\u6570<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h2>\u4e09\u3001\u7279\u6b8a\u65b9\u6cd5&#xff08;\u9b54\u672f\u65b9\u6cd5&#xff09;<\/h2>\n<p>\u4ee5\u53cc\u4e0b\u5212\u7ebf __ \u5305\u56f4\u7684\u65b9\u6cd5&#xff0c;\u7528\u4e8e\u91cd\u8f7d\u64cd\u4f5c\u7b26\u6216\u5b9a\u4e49\u5bf9\u8c61\u884c\u4e3a\u3002<\/p>\n<h4>(1) \u5e38\u7528\u9b54\u672f\u65b9\u6cd5<\/h4>\n<table>\n<tr>\u65b9\u6cd5\u540d\u4f5c\u7528\u793a\u4f8b<\/tr>\n<tbody>\n<tr>\n<td>__init__(self, &#8230;)<\/td>\n<td>\u6784\u9020\u65b9\u6cd5<\/td>\n<td>obj &#061; ClassName()<\/td>\n<\/tr>\n<tr>\n<td>__str__(self)<\/td>\n<td>\u5b9a\u4e49 print(obj) \u7684\u8f93\u51fa<\/td>\n<td>print(obj)<\/td>\n<\/tr>\n<tr>\n<td>__len__(self)<\/td>\n<td>\u5b9a\u4e49 len(obj) \u7684\u884c\u4e3a<\/td>\n<td>len(obj)<\/td>\n<\/tr>\n<tr>\n<td>__add__(self, other)<\/td>\n<td>\u91cd\u8f7d &#043; \u64cd\u4f5c\u7b26<\/td>\n<td>obj1 &#043; obj2<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>(2) \u793a\u4f8b<\/h4>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">Vector<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token keyword\">def<\/span> <span class=\"token function\">__init__<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">,<\/span> x<span class=\"token punctuation\">,<\/span> y<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>x <span class=\"token operator\">&#061;<\/span> x<br \/>\n        self<span class=\"token punctuation\">.<\/span>y <span class=\"token operator\">&#061;<\/span> y<\/p>\n<p>    <span class=\"token keyword\">def<\/span> <span class=\"token function\">__add__<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">,<\/span> other<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span>  <span class=\"token comment\"># \u91cd\u8f7d &#043;<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> Vector<span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">.<\/span>x <span class=\"token operator\">&#043;<\/span> other<span class=\"token punctuation\">.<\/span>x<span class=\"token punctuation\">,<\/span> self<span class=\"token punctuation\">.<\/span>y <span class=\"token operator\">&#043;<\/span> other<span class=\"token punctuation\">.<\/span>y<span class=\"token punctuation\">)<\/span><\/p>\n<p>    <span class=\"token keyword\">def<\/span> <span class=\"token function\">__str__<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span>         <span class=\"token comment\"># \u5b9a\u4e49\u6253\u5370\u683c\u5f0f<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token string-interpolation\"><span class=\"token string\">f&#034;Vector(<\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>self<span class=\"token punctuation\">.<\/span>x<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">, <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>self<span class=\"token punctuation\">.<\/span>y<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">)&#034;<\/span><\/span><\/p>\n<p>v1 <span class=\"token operator\">&#061;<\/span> Vector<span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span><br \/>\nv2 <span class=\"token operator\">&#061;<\/span> Vector<span class=\"token punctuation\">(<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">4<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>v1 <span class=\"token operator\">&#043;<\/span> v2<span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u8f93\u51fa: Vector(4, 6)<\/span><\/p>\n<hr \/>\n<h2>\u56db\u3001\u5c5e\u6027\u88c5\u9970\u5668&#xff08;&#064;property&#xff09;<\/h2>\n<p>\u5c06\u65b9\u6cd5\u4f2a\u88c5\u6210\u5c5e\u6027&#xff0c;\u7528\u4e8e\u63a7\u5236\u5c5e\u6027\u8bbf\u95ee\u3002<\/p>\n<h4>(1) \u57fa\u672c\u7528\u6cd5<\/h4>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">Circle<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token keyword\">def<\/span> <span class=\"token function\">__init__<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">,<\/span> radius<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>_radius <span class=\"token operator\">&#061;<\/span> radius  <span class=\"token comment\"># \u4fdd\u62a4\u5c5e\u6027<\/span><\/p>\n<p>    <span class=\"token decorator annotation punctuation\">&#064;property<\/span><br \/>\n    <span class=\"token keyword\">def<\/span> <span class=\"token function\">radius<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span>          <span class=\"token comment\"># \u83b7\u53d6\u5c5e\u6027<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> self<span class=\"token punctuation\">.<\/span>_radius<\/p>\n<p>    <span class=\"token decorator annotation punctuation\">&#064;radius<span class=\"token punctuation\">.<\/span>setter<\/span><br \/>\n    <span class=\"token keyword\">def<\/span> <span class=\"token function\">radius<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">,<\/span> value<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span>   <span class=\"token comment\"># \u8bbe\u7f6e\u5c5e\u6027<\/span><br \/>\n        <span class=\"token keyword\">if<\/span> value <span class=\"token operator\">&lt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">:<\/span><br \/>\n            <span class=\"token keyword\">raise<\/span> ValueError<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Radius cannot be negative&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>_radius <span class=\"token operator\">&#061;<\/span> value<\/p>\n<p>    <span class=\"token decorator annotation punctuation\">&#064;property<\/span><br \/>\n    <span class=\"token keyword\">def<\/span> <span class=\"token function\">area<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span>            <span class=\"token comment\"># \u53ea\u8bfb\u5c5e\u6027<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token number\">3.14<\/span> <span class=\"token operator\">*<\/span> self<span class=\"token punctuation\">.<\/span>_radius  <span class=\"token number\">2<\/span><\/p>\n<p>c <span class=\"token operator\">&#061;<\/span> Circle<span class=\"token punctuation\">(<\/span><span class=\"token number\">5<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>c<span class=\"token punctuation\">.<\/span>radius<span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u8f93\u51fa: 5 (\u50cf\u5c5e\u6027\u4e00\u6837\u8c03\u7528\u65b9\u6cd5)<\/span><br \/>\nc<span class=\"token punctuation\">.<\/span>radius <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">10<\/span>    <span class=\"token comment\"># \u8c03\u7528 setter<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>c<span class=\"token punctuation\">.<\/span>area<span class=\"token punctuation\">)<\/span>    <span class=\"token comment\"># \u8f93\u51fa: 314.0 (\u53ea\u8bfb)<\/span><\/p>\n<h4>(2) \u7528\u9014<\/h4>\n<ul>\n<li>\u6570\u636e\u9a8c\u8bc1&#xff08;\u5982\u9650\u5236 radius \u4e0d\u80fd\u4e3a\u8d1f&#xff09;\u3002<\/li>\n<li>\u52a8\u6001\u8ba1\u7b97\u5c5e\u6027&#xff08;\u5982 area \u57fa\u4e8e radius \u5b9e\u65f6\u8ba1\u7b97&#xff09;\u3002<\/li>\n<li>\u5411\u540e\u517c\u5bb9&#xff08;\u5c06\u65b9\u6cd5\u6539\u4e3a\u5c5e\u6027\u4e0d\u5f71\u54cd\u73b0\u6709\u4ee3\u7801&#xff09;\u3002<\/li>\n<\/ul>\n<hr \/>\n<h2>\u4e94\u3001\u6982\u5ff5\u603b\u7ed3<\/h2>\n<table>\n<tr>\u6982\u5ff5\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>\u5b9e\u4f8b\u5c5e\u6027<\/td>\n<td>\u6bcf\u4e2a\u5bf9\u8c61\u72ec\u6709\u7684\u6570\u636e&#xff0c;\u901a\u8fc7 self.attr \u5b9a\u4e49\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u7c7b\u5c5e\u6027<\/td>\n<td>\u6240\u6709\u5bf9\u8c61\u5171\u4eab\u7684\u6570\u636e&#xff0c;\u76f4\u63a5\u5b9a\u4e49\u5728\u7c7b\u4e2d\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u5b9e\u4f8b\u65b9\u6cd5<\/td>\n<td>\u64cd\u4f5c\u5b9e\u4f8b\u6570\u636e&#xff0c;\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e3a self\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u7c7b\u65b9\u6cd5<\/td>\n<td>\u64cd\u4f5c\u7c7b\u5c5e\u6027&#xff0c;\u7528 &#064;classmethod \u88c5\u9970&#xff0c;\u53c2\u6570\u4e3a cls\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u9759\u6001\u65b9\u6cd5<\/td>\n<td>\u72ec\u7acb\u5de5\u5177\u51fd\u6570&#xff0c;\u7528 &#064;staticmethod \u88c5\u9970&#xff0c;\u65e0 self \u6216 cls\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u9b54\u672f\u65b9\u6cd5<\/td>\n<td>\u53cc\u4e0b\u5212\u7ebf\u65b9\u6cd5&#xff08;\u5982 __init__&#xff09;&#xff0c;\u91cd\u8f7d\u5185\u7f6e\u884c\u4e3a\u3002<\/td>\n<\/tr>\n<tr>\n<td>&#064;property<\/td>\n<td>\u5c06\u65b9\u6cd5\u4f2a\u88c5\u6210\u5c5e\u6027&#xff0c;\u652f\u6301 getter\/setter \u903b\u8f91\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h2>\u516d\u3001\u5e94\u7528\u573a\u666f<\/h2>\n<li>\u5b9e\u4f8b\u5c5e\u6027&#xff1a;\u5b58\u50a8\u5bf9\u8c61\u72b6\u6001&#xff08;\u5982 Person.name&#xff09;\u3002<\/li>\n<li>\u7c7b\u5c5e\u6027&#xff1a;\u5171\u4eab\u914d\u7f6e&#xff08;\u5982 Database.connection_timeout&#xff09;\u3002<\/li>\n<li>\u5b9e\u4f8b\u65b9\u6cd5&#xff1a;\u5b9a\u4e49\u5bf9\u8c61\u884c\u4e3a&#xff08;\u5982 dog.bark()&#xff09;\u3002<\/li>\n<li>\u7c7b\u65b9\u6cd5&#xff1a;\u5de5\u5382\u6a21\u5f0f&#xff08;\u5982 Person.create_from_json()&#xff09;\u3002<\/li>\n<li>\u9759\u6001\u65b9\u6cd5&#xff1a;\u5de5\u5177\u51fd\u6570&#xff08;\u5982 MathUtils.add(a, b)&#xff09;\u3002<\/li>\n<li>&#064;property&#xff1a;\u6570\u636e\u6821\u9a8c\u6216\u8ba1\u7b97\u5c5e\u6027&#xff08;\u5982 Circle.area&#xff09;\u3002<\/li>\n<p>\u901a\u8fc7\u7075\u6d3b\u4f7f\u7528\u5c5e\u6027\u548c\u65b9\u6cd5&#xff0c;\u53ef\u4ee5\u6784\u5efa\u9ad8\u5185\u805a\u3001\u4f4e\u8026\u5408\u7684\u9762\u5411\u5bf9\u8c61 Python \u4ee3\u7801&#xff01;<\/p>\n<h2>\u5168\u6587\u603b\u7ed3<\/h2>\n<p>\u672c\u6587\u56f4\u7ed5Python\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u7684\u6838\u5fc3\u6982\u5ff5\u5c55\u5f00&#xff0c;\u9996\u5148\u5398\u6e05\u5c5e\u6027\u7c7b\u522b&#xff1a;\u5b9e\u4f8b\u5c5e\u6027\u7531\u5bf9\u8c61\u72ec\u4eab&#xff0c;\u5728__init__\u4e2d\u7528self\u521d\u59cb\u5316&#xff1b;\u7c7b\u5c5e\u6027\u7531\u7c7b\u672c\u8eab\u6301\u6709&#xff0c;\u6240\u6709\u5b9e\u4f8b\u5171\u4eab&#xff0c;\u53ef\u76f4\u63a5\u4fee\u6539\u3002\u63a5\u7740\u6309\u8c03\u7528\u65b9\u5f0f\u5c06\u65b9\u6cd5\u5206\u4e3a\u4e09\u7c7b&#xff1a;\u5b9e\u4f8b\u65b9\u6cd5\u4ee5self\u64cd\u4f5c\u5bf9\u8c61\u6570\u636e&#xff1b;\u7c7b\u65b9\u6cd5\u7528&#064;classmethod\u4ee5cls\u64cd\u4f5c\u7c7b\u72b6\u6001&#xff0c;\u5e38\u7528\u4e8e\u5de5\u5382\u6a21\u5f0f&#xff1b;\u9759\u6001\u65b9\u6cd5\u7528&#064;staticmethod&#xff0c;\u662f\u65e0\u72b6\u6001\u7684\u72ec\u7acb\u5de5\u5177\u51fd\u6570\u3002\u968f\u540e\u4ecb\u7ecd\u4ee5\u53cc\u4e0b\u5212\u7ebf\u5305\u56f4\u7684\u9b54\u672f\u65b9\u6cd5&#xff0c;\u901a\u8fc7\u91cd\u8f7d__add__\u3001__str__\u7b49\u8ba9\u5bf9\u8c61\u652f\u6301&#043;\u3001print\u7b49\u539f\u751f\u8bed\u6cd5\u3002\u6587\u7ae0\u91cd\u70b9\u793a\u8303&#064;property\u88c5\u9970\u5668&#xff1a;\u628a\u65b9\u6cd5\u4f2a\u88c5\u6210\u5c5e\u6027&#xff0c;\u5b9e\u73b0getter\u3001setter&#xff0c;\u53ef\u5728\u8bbf\u95ee\u65f6\u5b9e\u65f6\u6821\u9a8c\u6216\u8ba1\u7b97&#xff0c;\u4fdd\u969c\u6570\u636e\u5b89\u5168\u4e0e\u63a5\u53e3\u4e00\u81f4\u3002\u6700\u540e\u7ed9\u51fa\u5e38\u89c1\u573a\u666f&#xff1a;\u7528\u5b9e\u4f8b\u5c5e\u6027\u4fdd\u5b58\u5bf9\u8c61\u72b6\u6001\u3001\u7c7b\u5c5e\u6027\u5b58\u653e\u5168\u5c40\u914d\u7f6e\u3001\u7c7b\u65b9\u6cd5\u6784\u9020\u591a\u6001\u5b9e\u4f8b\u3001\u9759\u6001\u65b9\u6cd5\u63d0\u4f9b\u6570\u5b66\u5de5\u5177\u3001&#064;property\u5b8c\u6210\u52a8\u6001\u8ba1\u7b97\u4e0e\u8fb9\u754c\u6821\u9a8c\u3002\u638c\u63e1\u8fd9\u4e9b\u673a\u5236&#xff0c;\u5f00\u53d1\u8005\u5373\u53ef\u5199\u51fa\u7ed3\u6784\u6e05\u6670\u3001\u53ef\u6269\u5c55\u3001\u6613\u7ef4\u62a4\u7684Python\u9762\u5411\u5bf9\u8c61\u4ee3\u7801\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb23\u6b21\u3002\u672c\u6587\u7cfb\u7edf\u8bb2\u89e3Python\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u4e2d\u7684\u5c5e\u6027\u4e0e\u65b9\u6cd5\uff1a\u533a\u5206\u5b9e\u4f8b\u5c5e\u6027\u4e0e\u7c7b\u5c5e\u6027\uff0c\u4ecb\u7ecd\u5b9e\u4f8b\u3001\u7c7b\u3001\u9759\u6001\u65b9\u6cd5\u53ca\u9b54\u672f\u65b9\u6cd5\uff0c\u5c55\u793a@property\u5b9e\u73b0\u5c5e\u6027\u63a7\u5236\u4e0e\u6570\u636e\u9a8c\u8bc1\uff0c\u5e76\u7ed9\u51fa\u5178\u578b\u5e94\u7528\u573a\u666f\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u6784\u5efa\u9ad8\u5185\u805a\u4f4e\u8026\u5408\u7684\u4ee3\u7801\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[81,190,4406,5940,4405,5366],"topic":[],"class_list":["post-56986","post","type-post","status-publish","format-standard","hentry","category-server","tag-python","tag-190","tag-4406","tag-5940","tag-4405","tag-5366"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u7f16\u7a0b\u4e0e\u6570\u5b66 02-017 Python \u9762\u5411\u5bf9\u8c61\u7f16\u7a0b 03\u8bfe\u9898\u3001\u5c5e\u6027\u548c\u65b9\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/56986.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u7f16\u7a0b\u4e0e\u6570\u5b66 02-017 Python \u9762\u5411\u5bf9\u8c61\u7f16\u7a0b 03\u8bfe\u9898\u3001\u5c5e\u6027\u548c\u65b9\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb23\u6b21\u3002\u672c\u6587\u7cfb\u7edf\u8bb2\u89e3Python\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u4e2d\u7684\u5c5e\u6027\u4e0e\u65b9\u6cd5\uff1a\u533a\u5206\u5b9e\u4f8b\u5c5e\u6027\u4e0e\u7c7b\u5c5e\u6027\uff0c\u4ecb\u7ecd\u5b9e\u4f8b\u3001\u7c7b\u3001\u9759\u6001\u65b9\u6cd5\u53ca\u9b54\u672f\u65b9\u6cd5\uff0c\u5c55\u793a@property\u5b9e\u73b0\u5c5e\u6027\u63a7\u5236\u4e0e\u6570\u636e\u9a8c\u8bc1\uff0c\u5e76\u7ed9\u51fa\u5178\u578b\u5e94\u7528\u573a\u666f\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u6784\u5efa\u9ad8\u5185\u805a\u4f4e\u8026\u5408\u7684\u4ee3\u7801\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/56986.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-14T22:19:44+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/56986.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/56986.html\",\"name\":\"\u7f16\u7a0b\u4e0e\u6570\u5b66 02-017 Python \u9762\u5411\u5bf9\u8c61\u7f16\u7a0b 03\u8bfe\u9898\u3001\u5c5e\u6027\u548c\u65b9\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-14T22:19:44+00:00\",\"dateModified\":\"2025-08-14T22:19:44+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/56986.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/56986.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/56986.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u7f16\u7a0b\u4e0e\u6570\u5b66 02-017 Python \u9762\u5411\u5bf9\u8c61\u7f16\u7a0b 03\u8bfe\u9898\u3001\u5c5e\u6027\u548c\u65b9\u6cd5\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u7f16\u7a0b\u4e0e\u6570\u5b66 02-017 Python \u9762\u5411\u5bf9\u8c61\u7f16\u7a0b 03\u8bfe\u9898\u3001\u5c5e\u6027\u548c\u65b9\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","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:\/\/www.wsisp.com\/helps\/56986.html","og_locale":"zh_CN","og_type":"article","og_title":"\u7f16\u7a0b\u4e0e\u6570\u5b66 02-017 Python \u9762\u5411\u5bf9\u8c61\u7f16\u7a0b 03\u8bfe\u9898\u3001\u5c5e\u6027\u548c\u65b9\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb23\u6b21\u3002\u672c\u6587\u7cfb\u7edf\u8bb2\u89e3Python\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u4e2d\u7684\u5c5e\u6027\u4e0e\u65b9\u6cd5\uff1a\u533a\u5206\u5b9e\u4f8b\u5c5e\u6027\u4e0e\u7c7b\u5c5e\u6027\uff0c\u4ecb\u7ecd\u5b9e\u4f8b\u3001\u7c7b\u3001\u9759\u6001\u65b9\u6cd5\u53ca\u9b54\u672f\u65b9\u6cd5\uff0c\u5c55\u793a@property\u5b9e\u73b0\u5c5e\u6027\u63a7\u5236\u4e0e\u6570\u636e\u9a8c\u8bc1\uff0c\u5e76\u7ed9\u51fa\u5178\u578b\u5e94\u7528\u573a\u666f\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u6784\u5efa\u9ad8\u5185\u805a\u4f4e\u8026\u5408\u7684\u4ee3\u7801\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/56986.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-14T22:19:44+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/56986.html","url":"https:\/\/www.wsisp.com\/helps\/56986.html","name":"\u7f16\u7a0b\u4e0e\u6570\u5b66 02-017 Python \u9762\u5411\u5bf9\u8c61\u7f16\u7a0b 03\u8bfe\u9898\u3001\u5c5e\u6027\u548c\u65b9\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-14T22:19:44+00:00","dateModified":"2025-08-14T22:19:44+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/56986.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/56986.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/56986.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u7f16\u7a0b\u4e0e\u6570\u5b66 02-017 Python \u9762\u5411\u5bf9\u8c61\u7f16\u7a0b 03\u8bfe\u9898\u3001\u5c5e\u6027\u548c\u65b9\u6cd5"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/56986","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=56986"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/56986\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=56986"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=56986"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=56986"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=56986"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}