{"id":58218,"date":"2025-08-16T06:39:54","date_gmt":"2025-08-15T22:39:54","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/58218.html"},"modified":"2025-08-16T06:39:54","modified_gmt":"2025-08-15T22:39:54","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-05%e8%af%be%e9%a2%98%e3%80%81%e5%b0%81%e8%a3%85","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/58218.html","title":{"rendered":"\u7f16\u7a0b\u4e0e\u6570\u5b66 02-017 Python \u9762\u5411\u5bf9\u8c61\u7f16\u7a0b 05\u8bfe\u9898\u3001\u5c01\u88c5"},"content":{"rendered":"<\/p>\n<h4>\u7f16\u7a0b\u4e0e\u6570\u5b66 02-017 Python \u9762\u5411\u5bf9\u8c61\u7f16\u7a0b 05\u8bfe\u9898\u3001\u5c01\u88c5<\/h4>\n<ul>\n<li>\u4e00\u3001\u5c01\u88c5\u7684\u6838\u5fc3\u601d\u60f3<\/li>\n<li>\u4e8c\u3001Python \u5b9e\u73b0\u5c01\u88c5\u7684\u4e09\u79cd\u65b9\u5f0f<\/li>\n<li>\n<ul>\n<li>\n<ul>\n<li>(1) \u547d\u540d\u7ea6\u5b9a<\/li>\n<li>(2) \u4f7f\u7528 &#096;&#064;property&#096; \u63a7\u5236\u8bbf\u95ee<\/li>\n<li>(3) \u901a\u8fc7\u65b9\u6cd5\u66b4\u9732\u64cd\u4f5c<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u4e09\u3001\u5c01\u88c5\u7684\u4f18\u70b9<\/li>\n<li>\u56db\u3001\u5c01\u88c5\u7684\u5e38\u89c1\u5e94\u7528\u573a\u666f<\/li>\n<li>\n<ul>\n<li>\n<ul>\n<li>(1) \u6570\u636e\u9a8c\u8bc1<\/li>\n<li>(2) \u53ea\u8bfb\u5c5e\u6027<\/li>\n<li>(3) \u5ef6\u8fdf\u52a0\u8f7d&#xff08;Lazy Loading&#xff09;<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u4e94\u3001\u6ce8\u610f\u4e8b\u9879<\/li>\n<li>\u516d\u3001\u5c01\u88c5 vs \u975e\u5c01\u88c5\u5bf9\u6bd4<\/li>\n<li>\n<ul>\n<li>\n<ul>\n<li>\u975e\u5c01\u88c5\u793a\u4f8b&#xff08;\u98ce\u9669\u9ad8&#xff09;<\/li>\n<li>\u5c01\u88c5\u793a\u4f8b&#xff08;\u5b89\u5168&#xff09;<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u5168\u6587\u603b\u7ed3<\/li>\n<\/ul>\n<p>\u6458\u8981&#xff1a;\u5c01\u88c5\u901a\u8fc7\u547d\u540d\u7ea6\u5b9a\u3001&#064;property\u548c\u65b9\u6cd5\u66b4\u9732\u4e09\u79cd\u65b9\u5f0f\u9690\u85cf\u5b9e\u73b0\u7ec6\u8282&#xff0c;\u9632\u6b62\u975e\u6cd5\u4fee\u6539&#xff0c;\u7b80\u5316\u63a5\u53e3&#xff1b;\u4f18\u70b9\u662f\u6570\u636e\u4fdd\u62a4\u3001\u4f4e\u8026\u5408\u3001\u6613\u7ef4\u62a4\u3001\u9ad8\u7075\u6d3b\u6027&#xff0c;\u9002\u7528\u4e8e\u6570\u636e\u9a8c\u8bc1\u3001\u53ea\u8bfb\u5c5e\u6027\u4e0e\u5ef6\u8fdf\u52a0\u8f7d\u7b49\u573a\u666f\u3002<\/p>\n<p>\u5173\u952e\u8bcd&#xff1a;\u5c01\u88c5\u3001Python\u3001\u547d\u540d\u7ea6\u5b9a\u3001&#064;property\u3001\u6570\u636e\u4fdd\u62a4<\/p>\n<p>\u4eba\u5de5\u667a\u80fd\u52a9\u624b&#xff1a;Kimi<\/p>\n<hr \/>\n<h2>\u4e00\u3001\u5c01\u88c5\u7684\u6838\u5fc3\u601d\u60f3<\/h2>\n<ul>\n<li>\u9690\u85cf\u5b9e\u73b0\u7ec6\u8282&#xff1a;\u53ea\u66b4\u9732\u5fc5\u8981\u7684\u64cd\u4f5c\u63a5\u53e3&#xff0c;\u5185\u90e8\u903b\u8f91\u5bf9\u7528\u6237\u900f\u660e\u3002<\/li>\n<li>\u6570\u636e\u4fdd\u62a4&#xff1a;\u9632\u6b62\u5916\u90e8\u76f4\u63a5\u4fee\u6539\u5bf9\u8c61\u5185\u90e8\u72b6\u6001&#xff0c;\u907f\u514d\u975e\u6cd5\u64cd\u4f5c\u3002<\/li>\n<li>\u7b80\u5316\u4f7f\u7528&#xff1a;\u7528\u6237\u53ea\u9700\u77e5\u9053\u201c\u505a\u4ec0\u4e48\u201d&#xff0c;\u65e0\u9700\u5173\u5fc3\u201c\u600e\u4e48\u505a\u201d\u3002<\/li>\n<\/ul>\n<hr \/>\n<h2>\u4e8c\u3001Python \u5b9e\u73b0\u5c01\u88c5\u7684\u4e09\u79cd\u65b9\u5f0f<\/h2>\n<p>Python \u6ca1\u6709\u4e25\u683c\u7684 private \u6216 protected \u5173\u952e\u5b57&#xff0c;\u4f46\u901a\u8fc7\u4ee5\u4e0b\u7ea6\u5b9a\u5b9e\u73b0\u5c01\u88c5&#xff1a;<\/p>\n<h4>(1) \u547d\u540d\u7ea6\u5b9a<\/h4>\n<ul>\n<li>\u516c\u6709\u6210\u5458&#xff1a;\u76f4\u63a5\u516c\u5f00&#xff08;\u5982 name&#xff09;\u3002<\/li>\n<li>\u53d7\u4fdd\u62a4\u6210\u5458&#xff1a;\u5355\u4e0b\u5212\u7ebf _ \u524d\u7f00&#xff08;\u7ea6\u5b9a\u4fd7\u6210&#xff0c;\u975e\u5f3a\u5236&#xff09;\u3002<\/li>\n<li>\u79c1\u6709\u6210\u5458&#xff1a;\u53cc\u4e0b\u5212\u7ebf __ \u524d\u7f00&#xff08;\u89e6\u53d1\u540d\u79f0\u4fee\u9970&#xff0c;\u907f\u514d\u76f4\u63a5\u8bbf\u95ee&#xff09;\u3002<\/li>\n<\/ul>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">BankAccount<\/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> balance<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>balance <span class=\"token operator\">&#061;<\/span> balance     <span class=\"token comment\"># \u516c\u6709\u5c5e\u6027<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>_account_id <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;123&#034;<\/span>   <span class=\"token comment\"># \u53d7\u4fdd\u62a4\u5c5e\u6027&#xff08;\u7ea6\u5b9a&#xff09;<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>__pin <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;0000&#034;<\/span>        <span class=\"token comment\"># \u79c1\u6709\u5c5e\u6027&#xff08;\u540d\u79f0\u4fee\u9970\u4e3a _BankAccount__pin&#xff09;<\/span><\/p>\n<p>account <span class=\"token operator\">&#061;<\/span> BankAccount<span class=\"token punctuation\">(<\/span><span class=\"token number\">1000<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>account<span class=\"token punctuation\">.<\/span>balance<span class=\"token punctuation\">)<\/span>       <span class=\"token comment\"># \u6b63\u5e38\u8bbf\u95ee&#xff1a;1000<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>account<span class=\"token punctuation\">.<\/span>_account_id<span class=\"token punctuation\">)<\/span>   <span class=\"token comment\"># \u4ecd\u53ef\u8bbf\u95ee&#xff08;\u4f46\u4e0d\u63a8\u8350&#xff09;&#xff1a;123<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>account<span class=\"token punctuation\">.<\/span>__pin<span class=\"token punctuation\">)<\/span>         <span class=\"token comment\"># \u62a5\u9519&#xff01;\u5b9e\u9645\u9700\u8bbf\u95ee account._BankAccount__pin<\/span><\/p>\n<h4>(2) \u4f7f\u7528 &#064;property \u63a7\u5236\u8bbf\u95ee<\/h4>\n<ul>\n<li>\u5c06\u65b9\u6cd5\u4f2a\u88c5\u6210\u5c5e\u6027&#xff0c;\u901a\u8fc7 getter\/setter \u6dfb\u52a0\u903b\u8f91\u3002<\/li>\n<li>\u4f18\u70b9&#xff1a;\u4fdd\u6301\u63a5\u53e3\u4e00\u81f4\u6027&#xff0c;\u540c\u65f6\u5b9e\u73b0\u6570\u636e\u9a8c\u8bc1\u3002<\/li>\n<\/ul>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">Temperature<\/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> celsius<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>_celsius <span class=\"token operator\">&#061;<\/span> celsius  <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\">celsius<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span>          <span class=\"token comment\"># Getter<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> self<span class=\"token punctuation\">.<\/span>_celsius<\/p>\n<p>    <span class=\"token decorator annotation punctuation\">&#064;celsius<span class=\"token punctuation\">.<\/span>setter<\/span><br \/>\n    <span class=\"token keyword\">def<\/span> <span class=\"token function\">celsius<\/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\"># Setter&#xff08;\u53ef\u6dfb\u52a0\u6821\u9a8c&#xff09;<\/span><br \/>\n        <span class=\"token keyword\">if<\/span> value <span class=\"token operator\">&lt;<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token number\">273.15<\/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;\u6e29\u5ea6\u4e0d\u80fd\u4f4e\u4e8e\u7edd\u5bf9\u96f6\u5ea6&#xff01;&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>_celsius <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\">fahrenheit<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span>      <span class=\"token comment\"># \u8ba1\u7b97\u5c5e\u6027&#xff08;\u53ea\u8bfb&#xff09;<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> self<span class=\"token punctuation\">.<\/span>_celsius <span class=\"token operator\">*<\/span> <span class=\"token number\">9<\/span><span class=\"token operator\">\/<\/span><span class=\"token number\">5<\/span> <span class=\"token operator\">&#043;<\/span> <span class=\"token number\">32<\/span><\/p>\n<p>temp <span class=\"token operator\">&#061;<\/span> Temperature<span class=\"token punctuation\">(<\/span><span class=\"token number\">25<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>temp<span class=\"token punctuation\">.<\/span>celsius<span class=\"token punctuation\">)<\/span>        <span class=\"token comment\"># 25<\/span><br \/>\ntemp<span class=\"token punctuation\">.<\/span>celsius <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">30<\/span>          <span class=\"token comment\"># \u901a\u8fc7 setter \u4fee\u6539<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>temp<span class=\"token punctuation\">.<\/span>fahrenheit<span class=\"token punctuation\">)<\/span>     <span class=\"token comment\"># 86.0&#xff08;\u53ea\u8bfb\u5c5e\u6027&#xff09;<\/span><br \/>\ntemp<span class=\"token punctuation\">.<\/span>celsius <span class=\"token operator\">&#061;<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token number\">300<\/span>        <span class=\"token comment\"># \u89e6\u53d1 ValueError<\/span><\/p>\n<h4>(3) \u901a\u8fc7\u65b9\u6cd5\u66b4\u9732\u64cd\u4f5c<\/h4>\n<p>\u7981\u6b62\u76f4\u63a5\u4fee\u6539\u5c5e\u6027&#xff0c;\u5f3a\u5236\u901a\u8fc7\u65b9\u6cd5\u64cd\u4f5c\u6570\u636e\u3002<\/p>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">LightSwitch<\/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>__is_on <span class=\"token operator\">&#061;<\/span> <span class=\"token boolean\">False<\/span>  <span class=\"token comment\"># \u79c1\u6709\u5c5e\u6027<\/span><\/p>\n<p>    <span class=\"token keyword\">def<\/span> <span class=\"token function\">turn_on<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span>        <span class=\"token comment\"># \u516c\u6709\u65b9\u6cd5<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>__is_on <span class=\"token operator\">&#061;<\/span> <span class=\"token boolean\">True<\/span><\/p>\n<p>    <span class=\"token keyword\">def<\/span> <span class=\"token function\">turn_off<\/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>__is_on <span class=\"token operator\">&#061;<\/span> <span class=\"token boolean\">False<\/span><\/p>\n<p>    <span class=\"token keyword\">def<\/span> <span class=\"token function\">status<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token string\">&#034;\u5f00&#034;<\/span> <span class=\"token keyword\">if<\/span> self<span class=\"token punctuation\">.<\/span>__is_on <span class=\"token keyword\">else<\/span> <span class=\"token string\">&#034;\u5173&#034;<\/span><\/p>\n<p>switch <span class=\"token operator\">&#061;<\/span> LightSwitch<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\nswitch<span class=\"token punctuation\">.<\/span>turn_on<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>switch<span class=\"token punctuation\">.<\/span>status<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u8f93\u51fa: \u5f00<\/span><br \/>\n<span class=\"token comment\"># switch.__is_on &#061; True  # \u62a5\u9519&#xff01;\u65e0\u6cd5\u76f4\u63a5\u8bbf\u95ee\u79c1\u6709\u5c5e\u6027<\/span><\/p>\n<hr \/>\n<h2>\u4e09\u3001\u5c01\u88c5\u7684\u4f18\u70b9<\/h2>\n<table>\n<tr>\u4f18\u70b9\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>\u6570\u636e\u4fdd\u62a4<\/td>\n<td>\u9632\u6b62\u5916\u90e8\u4ee3\u7801\u610f\u5916\u4fee\u6539\u5173\u952e\u6570\u636e&#xff08;\u5982\u94f6\u884c\u8d26\u6237\u4f59\u989d&#xff09;\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u964d\u4f4e\u8026\u5408<\/td>\n<td>\u9690\u85cf\u5b9e\u73b0\u7ec6\u8282&#xff0c;\u4fee\u6539\u5185\u90e8\u903b\u8f91\u4e0d\u5f71\u54cd\u5916\u90e8\u8c03\u7528\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u6613\u4e8e\u7ef4\u62a4<\/td>\n<td>\u4ee3\u7801\u6a21\u5757\u5316&#xff0c;\u9519\u8bef\u66f4\u5bb9\u6613\u5b9a\u4f4d\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u7075\u6d3b\u6027<\/td>\n<td>\u53ef\u5728 getter\/setter \u4e2d\u6dfb\u52a0\u989d\u5916\u903b\u8f91&#xff08;\u5982\u65e5\u5fd7\u3001\u6821\u9a8c&#xff09;\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h2>\u56db\u3001\u5c01\u88c5\u7684\u5e38\u89c1\u5e94\u7528\u573a\u666f<\/h2>\n<h4>(1) \u6570\u636e\u9a8c\u8bc1<\/h4>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">User<\/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> username<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>username <span class=\"token operator\">&#061;<\/span> username  <span class=\"token comment\"># \u901a\u8fc7 setter \u6821\u9a8c<\/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\">username<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> self<span class=\"token punctuation\">.<\/span>__username<\/p>\n<p>    <span class=\"token decorator annotation punctuation\">&#064;username<span class=\"token punctuation\">.<\/span>setter<\/span><br \/>\n    <span class=\"token keyword\">def<\/span> <span class=\"token function\">username<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">,<\/span> value<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">if<\/span> <span class=\"token keyword\">not<\/span> value<span class=\"token punctuation\">.<\/span>isalnum<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/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;\u7528\u6237\u540d\u53ea\u80fd\u5305\u542b\u5b57\u6bcd\u548c\u6570\u5b57&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>__username <span class=\"token operator\">&#061;<\/span> value<\/p>\n<p>user <span class=\"token operator\">&#061;<\/span> User<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Alice123&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\nuser<span class=\"token punctuation\">.<\/span>username <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;Bob!&#034;<\/span>  <span class=\"token comment\"># \u89e6\u53d1 ValueError<\/span><\/p>\n<h4>(2) \u53ea\u8bfb\u5c5e\u6027<\/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<\/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\"># \u53ea\u8bfb getter<\/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;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\"># \u52a8\u6001\u8ba1\u7b97\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>area<span class=\"token punctuation\">)<\/span>     <span class=\"token comment\"># 78.5<\/span><br \/>\n<span class=\"token comment\"># c.radius &#061; 10   # \u62a5\u9519&#xff01;\u65e0 setter<\/span><\/p>\n<h4>(3) \u5ef6\u8fdf\u52a0\u8f7d&#xff08;Lazy Loading&#xff09;<\/h4>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">Database<\/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>__connection <span class=\"token operator\">&#061;<\/span> <span class=\"token boolean\">None<\/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\">connection<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">if<\/span> self<span class=\"token punctuation\">.<\/span>__connection <span class=\"token keyword\">is<\/span> <span class=\"token boolean\">None<\/span><span class=\"token punctuation\">:<\/span><br \/>\n            self<span class=\"token punctuation\">.<\/span>__connection <span class=\"token operator\">&#061;<\/span> self<span class=\"token punctuation\">.<\/span>__connect<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> self<span class=\"token punctuation\">.<\/span>__connection<\/p>\n<p>    <span class=\"token keyword\">def<\/span> <span class=\"token function\">__connect<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u5efa\u7acb\u6570\u636e\u5e93\u8fde\u63a5&#8230;&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token string\">&#034;Connection Object&#034;<\/span><\/p>\n<p>db <span class=\"token operator\">&#061;<\/span> Database<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>db<span class=\"token punctuation\">.<\/span>connection<span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u7b2c\u4e00\u6b21\u8c03\u7528\u65f6\u521d\u59cb\u5316\u8fde\u63a5<\/span><\/p>\n<hr \/>\n<h2>\u4e94\u3001\u6ce8\u610f\u4e8b\u9879<\/h2>\n<li>Python \u6ca1\u6709\u771f\u6b63\u7684\u79c1\u6709\u6210\u5458&#xff1a;\n<ul>\n<li>\u53cc\u4e0b\u5212\u7ebf __ \u4ec5\u89e6\u53d1\u540d\u79f0\u4fee\u9970&#xff08;\u5982 __attr \u53d8\u4e3a _ClassName__attr&#xff09;&#xff0c;\u4ecd\u53ef\u5f3a\u5236\u8bbf\u95ee&#xff0c;\u4f46\u7ea6\u5b9a\u7981\u6b62\u8fd9\u6837\u505a\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u907f\u514d\u8fc7\u5ea6\u5c01\u88c5&#xff1a;\n<ul>\n<li>\u7b80\u5355\u6570\u636e\u7c7b&#xff08;\u5982 DTO&#xff09;\u53ef\u80fd\u4e0d\u9700\u8981 getter\/setter\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u4f18\u5148\u4f7f\u7528 &#064;property&#xff1a;\n<ul>\n<li>\u6bd4 Java \u98ce\u683c\u7684 get_xxx()\/set_xxx() \u66f4 Pythonic\u3002<\/li>\n<\/ul>\n<\/li>\n<hr \/>\n<h2>\u516d\u3001\u5c01\u88c5 vs \u975e\u5c01\u88c5\u5bf9\u6bd4<\/h2>\n<h4>\u975e\u5c01\u88c5\u793a\u4f8b&#xff08;\u98ce\u9669\u9ad8&#xff09;<\/h4>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">BankAccount<\/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> balance<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>balance <span class=\"token operator\">&#061;<\/span> balance  <span class=\"token comment\"># \u76f4\u63a5\u66b4\u9732\u5c5e\u6027<\/span><\/p>\n<p>account <span class=\"token operator\">&#061;<\/span> BankAccount<span class=\"token punctuation\">(<\/span><span class=\"token number\">1000<\/span><span class=\"token punctuation\">)<\/span><br \/>\naccount<span class=\"token punctuation\">.<\/span>balance <span class=\"token operator\">&#061;<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token number\">500<\/span>  <span class=\"token comment\"># \u975e\u6cd5\u64cd\u4f5c&#xff0c;\u4f46\u65e0\u6cd5\u963b\u6b62<\/span><\/p>\n<h4>\u5c01\u88c5\u793a\u4f8b&#xff08;\u5b89\u5168&#xff09;<\/h4>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">BankAccount<\/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> balance<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>__balance <span class=\"token operator\">&#061;<\/span> balance<\/p>\n<p>    <span class=\"token keyword\">def<\/span> <span class=\"token function\">deposit<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">,<\/span> amount<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">if<\/span> amount <span class=\"token operator\">&gt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">:<\/span><br \/>\n            self<span class=\"token punctuation\">.<\/span>__balance <span class=\"token operator\">&#043;&#061;<\/span> amount<\/p>\n<p>    <span class=\"token keyword\">def<\/span> <span class=\"token function\">withdraw<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">,<\/span> amount<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">if<\/span> <span class=\"token number\">0<\/span> <span class=\"token operator\">&lt;<\/span> amount <span class=\"token operator\">&lt;&#061;<\/span> self<span class=\"token punctuation\">.<\/span>__balance<span class=\"token punctuation\">:<\/span><br \/>\n            self<span class=\"token punctuation\">.<\/span>__balance <span class=\"token operator\">-&#061;<\/span> amount<\/p>\n<p>    <span class=\"token keyword\">def<\/span> <span class=\"token function\">get_balance<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> self<span class=\"token punctuation\">.<\/span>__balance<\/p>\n<p>account <span class=\"token operator\">&#061;<\/span> BankAccount<span class=\"token punctuation\">(<\/span><span class=\"token number\">1000<\/span><span class=\"token punctuation\">)<\/span><br \/>\naccount<span class=\"token punctuation\">.<\/span>withdraw<span class=\"token punctuation\">(<\/span><span class=\"token number\">500<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u5fc5\u987b\u901a\u8fc7\u65b9\u6cd5\u64cd\u4f5c<\/span><br \/>\n<span class=\"token comment\"># account.__balance &#061; -1000  # \u65e0\u6cd5\u76f4\u63a5\u4fee\u6539<\/span><\/p>\n<hr \/>\n<h2>\u5168\u6587\u603b\u7ed3<\/h2>\n<p>\u5c01\u88c5\u662f\u9762\u5411\u5bf9\u8c61\u7684\u6838\u5fc3\u539f\u5219&#xff0c;\u65e8\u5728\u9690\u85cf\u5b9e\u73b0\u7ec6\u8282\u3001\u4fdd\u62a4\u6570\u636e\u5e76\u7b80\u5316\u4f7f\u7528\u3002Python \u901a\u8fc7\u5355\u4e0b\u5212\u7ebf\u201c_\u201d\u548c\u53cc\u4e0b\u5212\u7ebf\u201c__\u201d\u5b9e\u73b0\u53d7\u4fdd\u62a4\u4e0e\u79c1\u6709\u6210\u5458\u7684\u547d\u540d\u7ea6\u5b9a&#xff0c;\u914d\u5408\u540d\u79f0\u4fee\u9970\u673a\u5236\u9632\u6b62\u76f4\u63a5\u8bbf\u95ee&#xff1b;&#064;property \u88c5\u9970\u5668\u5c06\u65b9\u6cd5\u4f2a\u88c5\u6210\u5c5e\u6027&#xff0c;\u5728\u4fdd\u6301\u63a5\u53e3\u4e00\u81f4\u7684\u540c\u65f6\u52a0\u5165\u6821\u9a8c\u3001\u65e5\u5fd7\u7b49\u903b\u8f91&#xff1b;\u4e5f\u53ef\u901a\u8fc7\u4e13\u95e8\u7684\u516c\u6709\u65b9\u6cd5\u5f3a\u5236\u6240\u6709\u64cd\u4f5c\u90fd\u8d70\u7edf\u4e00\u5165\u53e3\u3002\u5c01\u88c5\u5e26\u6765\u6570\u636e\u5b89\u5168\u3001\u4f4e\u8026\u5408\u3001\u6613\u7ef4\u62a4\u4e0e\u7075\u6d3b\u6027&#xff0c;\u5e38\u7528\u4e8e\u6570\u636e\u9a8c\u8bc1\u3001\u53ea\u8bfb\u5c5e\u6027\u3001\u5ef6\u8fdf\u52a0\u8f7d\u7b49\u573a\u666f\u3002\u4f46 Python \u6ca1\u6709\u7edd\u5bf9\u79c1\u6709&#xff0c;\u4ecd\u9700\u5f00\u53d1\u8005\u81ea\u5f8b&#xff1b;\u7b80\u5355\u6570\u636e\u7c7b\u4e0d\u5b9c\u8fc7\u5ea6\u5c01\u88c5\u3002\u5408\u7406\u4f7f\u7528\u5c01\u88c5&#xff0c;\u53ef\u6784\u5efa\u5065\u58ee\u3001\u6613\u7ef4\u62a4\u7684\u4ee3\u7801\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb242\u6b21\u3002\u5c01\u88c5\u901a\u8fc7\u547d\u540d\u7ea6\u5b9a\u3001@property\u548c\u65b9\u6cd5\u66b4\u9732\u4e09\u79cd\u65b9\u5f0f\u9690\u85cf\u5b9e\u73b0\u7ec6\u8282\uff0c\u9632\u6b62\u975e\u6cd5\u4fee\u6539\uff0c\u7b80\u5316\u63a5\u53e3\uff1b\u4f18\u70b9\u662f\u6570\u636e\u4fdd\u62a4\u3001\u4f4e\u8026\u5408\u3001\u6613\u7ef4\u62a4\u3001\u9ad8\u7075\u6d3b\u6027\uff0c\u9002\u7528\u4e8e\u6570\u636e\u9a8c\u8bc1\u3001\u53ea\u8bfb\u5c5e\u6027\u4e0e\u5ef6\u8fdf\u52a0\u8f7d\u7b49\u573a\u666f\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-58218","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 05\u8bfe\u9898\u3001\u5c01\u88c5 - \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\/58218.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 05\u8bfe\u9898\u3001\u5c01\u88c5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb242\u6b21\u3002\u5c01\u88c5\u901a\u8fc7\u547d\u540d\u7ea6\u5b9a\u3001@property\u548c\u65b9\u6cd5\u66b4\u9732\u4e09\u79cd\u65b9\u5f0f\u9690\u85cf\u5b9e\u73b0\u7ec6\u8282\uff0c\u9632\u6b62\u975e\u6cd5\u4fee\u6539\uff0c\u7b80\u5316\u63a5\u53e3\uff1b\u4f18\u70b9\u662f\u6570\u636e\u4fdd\u62a4\u3001\u4f4e\u8026\u5408\u3001\u6613\u7ef4\u62a4\u3001\u9ad8\u7075\u6d3b\u6027\uff0c\u9002\u7528\u4e8e\u6570\u636e\u9a8c\u8bc1\u3001\u53ea\u8bfb\u5c5e\u6027\u4e0e\u5ef6\u8fdf\u52a0\u8f7d\u7b49\u573a\u666f\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/58218.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-15T22:39:54+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=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/58218.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/58218.html\",\"name\":\"\u7f16\u7a0b\u4e0e\u6570\u5b66 02-017 Python \u9762\u5411\u5bf9\u8c61\u7f16\u7a0b 05\u8bfe\u9898\u3001\u5c01\u88c5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-15T22:39:54+00:00\",\"dateModified\":\"2025-08-15T22:39:54+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/58218.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/58218.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/58218.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 05\u8bfe\u9898\u3001\u5c01\u88c5\"}]},{\"@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 05\u8bfe\u9898\u3001\u5c01\u88c5 - \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\/58218.html","og_locale":"zh_CN","og_type":"article","og_title":"\u7f16\u7a0b\u4e0e\u6570\u5b66 02-017 Python \u9762\u5411\u5bf9\u8c61\u7f16\u7a0b 05\u8bfe\u9898\u3001\u5c01\u88c5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb242\u6b21\u3002\u5c01\u88c5\u901a\u8fc7\u547d\u540d\u7ea6\u5b9a\u3001@property\u548c\u65b9\u6cd5\u66b4\u9732\u4e09\u79cd\u65b9\u5f0f\u9690\u85cf\u5b9e\u73b0\u7ec6\u8282\uff0c\u9632\u6b62\u975e\u6cd5\u4fee\u6539\uff0c\u7b80\u5316\u63a5\u53e3\uff1b\u4f18\u70b9\u662f\u6570\u636e\u4fdd\u62a4\u3001\u4f4e\u8026\u5408\u3001\u6613\u7ef4\u62a4\u3001\u9ad8\u7075\u6d3b\u6027\uff0c\u9002\u7528\u4e8e\u6570\u636e\u9a8c\u8bc1\u3001\u53ea\u8bfb\u5c5e\u6027\u4e0e\u5ef6\u8fdf\u52a0\u8f7d\u7b49\u573a\u666f\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/58218.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-15T22:39:54+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/58218.html","url":"https:\/\/www.wsisp.com\/helps\/58218.html","name":"\u7f16\u7a0b\u4e0e\u6570\u5b66 02-017 Python \u9762\u5411\u5bf9\u8c61\u7f16\u7a0b 05\u8bfe\u9898\u3001\u5c01\u88c5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-15T22:39:54+00:00","dateModified":"2025-08-15T22:39:54+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/58218.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/58218.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/58218.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 05\u8bfe\u9898\u3001\u5c01\u88c5"}]},{"@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\/58218","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=58218"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/58218\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=58218"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=58218"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=58218"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=58218"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}