{"id":960693,"date":"2024-12-27T03:51:55","date_gmt":"2024-12-26T19:51:55","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/960693.html"},"modified":"2024-12-27T03:51:57","modified_gmt":"2024-12-26T19:51:57","slug":"python%e4%b8%ad%e5%a6%82%e4%bd%95%e6%9f%a5%e7%9c%8b%e7%b1%bb%e5%9e%8b","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/960693.html","title":{"rendered":"python\u4e2d\u5982\u4f55\u67e5\u770b\u7c7b\u578b"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25103122\/a32ee489-8f12-427e-840c-5da4cdd59d27.webp\" alt=\"python\u4e2d\u5982\u4f55\u67e5\u770b\u7c7b\u578b\" \/><\/p>\n<p><p> \u4e00\u3001\u67e5\u770bPython\u4e2d\u53d8\u91cf\u7c7b\u578b\u7684\u65b9\u6cd5  <\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\u67e5\u770b\u53d8\u91cf\u7c7b\u578b\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c<strong>\u4f7f\u7528\u5185\u7f6e\u51fd\u6570<code>type()<\/code>\u3001\u4f7f\u7528<code>isinstance()<\/code>\u51fd\u6570\u3001\u4f7f\u7528<code>__class__<\/code>\u5c5e\u6027<\/strong>\u662f\u6700\u5e38\u89c1\u7684\u65b9\u5f0f\u3002\u9996\u5148\uff0c<code>type()<\/code>\u51fd\u6570\u662f\u6700\u76f4\u63a5\u7684\u65b9\u5f0f\uff0c\u5b83\u8fd4\u56de\u4e00\u4e2a\u53d8\u91cf\u7684\u7c7b\u578b\u3002\u5176\u6b21\uff0c<code>isinstance()<\/code>\u51fd\u6570\u4e0d\u4ec5\u53ef\u4ee5\u68c0\u67e5\u53d8\u91cf\u7684\u7c7b\u578b\uff0c\u8fd8\u53ef\u4ee5\u68c0\u67e5\u5176\u662f\u5426\u4e3a\u7279\u5b9a\u7c7b\u578b\u7684\u5b50\u7c7b\u3002\u6700\u540e\uff0c<code>__class__<\/code>\u5c5e\u6027\u4e5f\u53ef\u4ee5\u7528\u4e8e\u67e5\u770b\u5bf9\u8c61\u7684\u7c7b\u4fe1\u606f\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c<code>type()<\/code>\u51fd\u6570\u662f\u6700\u5e38\u7528\u7684\uff0c\u56e0\u4e3a\u5b83\u7b80\u5355\u76f4\u63a5\u3002\u4e0b\u9762\u6211\u4eec\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u51e0\u79cd\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><p><code>type()<\/code>\u51fd\u6570\u662fPython\u5185\u7f6e\u51fd\u6570\u4e4b\u4e00\uff0c\u7528\u4e8e\u8fd4\u56de\u5bf9\u8c61\u7684\u7c7b\u578b\u3002\u4f7f\u7528\u65b9\u6cd5\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u5c06\u9700\u8981\u68c0\u67e5\u7684\u53d8\u91cf\u4f5c\u4e3a\u53c2\u6570\u4f20\u5165\u5373\u53ef\u3002\u4f8b\u5982\uff0c<code>type(123)<\/code>\u5c06\u8fd4\u56de<code>&lt;class &#39;int&#39;&gt;<\/code>\uff0c\u8868\u793a\u53d8\u91cf\u662f\u6574\u6570\u7c7b\u578b\u3002<code>type()<\/code>\u51fd\u6570\u7684\u4f18\u70b9\u662f\u7b80\u5355\u3001\u6613\u7528\uff0c\u5e76\u4e14\u9002\u7528\u4e8e\u6240\u6709Python\u5185\u7f6e\u6570\u636e\u7c7b\u578b\u3002\u7136\u800c\uff0c<code>type()<\/code>\u5728\u5224\u65ad\u5bf9\u8c61\u662f\u5426\u4e3a\u67d0\u4e00\u7c7b\u578b\u7684\u5b50\u7c7b\u65f6\u663e\u5f97\u4e0d\u591f\u7075\u6d3b\uff0c\u8fd9\u65f6\u5c31\u9700\u8981\u4f7f\u7528<code>isinstance()<\/code>\u51fd\u6570\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u4f7f\u7528<code>type()<\/code>\u51fd\u6570\u67e5\u770b\u7c7b\u578b  <\/p>\n<\/p>\n<p><p><code>type()<\/code>\u51fd\u6570\u662fPython\u4e2d\u6700\u5e38\u7528\u7684\u67e5\u770b\u53d8\u91cf\u7c7b\u578b\u7684\u65b9\u6cd5\u3002\u5b83\u7684\u7528\u6cd5\u975e\u5e38\u76f4\u89c2\uff0c\u53ea\u9700\u5c06\u53d8\u91cf\u4f20\u5165<code>type()<\/code>\u51fd\u6570\u5373\u53ef\u3002\u8fd9\u4e2a\u65b9\u6cd5\u4e0d\u4ec5\u9002\u7528\u4e8e\u57fa\u672c\u6570\u636e\u7c7b\u578b\uff0c\u5982\u6574\u6570\u3001\u6d6e\u70b9\u6570\u3001\u5b57\u7b26\u4e32\u7b49\uff0c\u4e5f\u9002\u7528\u4e8e\u7528\u6237\u81ea\u5b9a\u4e49\u7684\u7c7b\u548c\u5bf9\u8c61\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u57fa\u672c\u7528\u6cd5<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528<code>type()<\/code>\u51fd\u6570\u65f6\uff0c\u53ea\u9700\u5c06\u53d8\u91cf\u4f5c\u4e3a\u53c2\u6570\u4f20\u5165\u5373\u53ef\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">num = 100<\/p>\n<p>print(type(num))  # \u8f93\u51fa\uff1a&lt;class &#39;int&#39;&gt;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4ee5\u4e0a\u4ee3\u7801\u5c06\u8f93\u51fa\u53d8\u91cf<code>num<\/code>\u7684\u7c7b\u578b\uff0c\u5373\u6574\u6570\uff08<code>int<\/code>\uff09\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9002\u7528\u4e8e\u590d\u6742\u7c7b\u578b<\/strong><\/p>\n<\/p>\n<p><p><code>type()<\/code>\u51fd\u6570\u4e0d\u4ec5\u9002\u7528\u4e8e\u57fa\u672c\u6570\u636e\u7c7b\u578b\uff0c\u8fd8\u53ef\u4ee5\u7528\u4e8e\u67e5\u770b\u590d\u6742\u6570\u636e\u7c7b\u578b\uff0c\u5982\u5217\u8868\u3001\u5b57\u5178\u3001\u5143\u7ec4\u7b49\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">my_list = [1, 2, 3]<\/p>\n<p>print(type(my_list))  # \u8f93\u51fa\uff1a&lt;class &#39;list&#39;&gt;<\/p>\n<p>my_dict = {&quot;key&quot;: &quot;value&quot;}<\/p>\n<p>print(type(my_dict))  # \u8f93\u51fa\uff1a&lt;class &#39;dict&#39;&gt;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4e0e\u81ea\u5b9a\u4e49\u7c7b\u7ed3\u5408<\/strong><\/p>\n<\/p>\n<p><p>\u5f53\u5e94\u7528\u4e8e\u81ea\u5b9a\u4e49\u7c7b\u7684\u5b9e\u4f8b\u65f6\uff0c<code>type()<\/code>\u51fd\u6570\u540c\u6837\u6709\u6548\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">class MyClass:<\/p>\n<p>    pass<\/p>\n<p>obj = MyClass()<\/p>\n<p>print(type(obj))  # \u8f93\u51fa\uff1a&lt;class &#39;__m<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>n__.MyClass&#39;&gt;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<p><p>\u4e09\u3001\u4f7f\u7528<code>isinstance()<\/code>\u51fd\u6570\u5224\u65ad\u7c7b\u578b  <\/p>\n<\/p>\n<p><p><code>isinstance()<\/code>\u51fd\u6570\u63d0\u4f9b\u4e86\u4e00\u79cd\u66f4\u4e3a\u7075\u6d3b\u7684\u65b9\u5f0f\u6765\u68c0\u67e5\u53d8\u91cf\u7684\u7c7b\u578b\u3002\u9664\u4e86\u53ef\u4ee5\u68c0\u67e5\u53d8\u91cf\u7684\u76f4\u63a5\u7c7b\u578b\u5916\uff0c\u5b83\u8fd8\u53ef\u4ee5\u68c0\u67e5\u53d8\u91cf\u662f\u5426\u5c5e\u4e8e\u67d0\u4e00\u7c7b\u578b\u7684\u5b50\u7c7b\u3002\u8fd9\u5728\u8fdb\u884c\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u65f6\u5c24\u5176\u6709\u7528\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u57fa\u672c\u7528\u6cd5<\/strong><\/p>\n<\/p>\n<p><p><code>isinstance()<\/code>\u51fd\u6570\u63a5\u53d7\u4e24\u4e2a\u53c2\u6570\uff1a\u7b2c\u4e00\u4e2a\u662f\u8981\u68c0\u67e5\u7684\u5bf9\u8c61\uff0c\u7b2c\u4e8c\u4e2a\u662f\u8981\u68c0\u67e5\u7684\u7c7b\u578b\u3002\u8fd4\u56de\u503c\u662f\u5e03\u5c14\u503c\uff0c\u8868\u793a\u5bf9\u8c61\u662f\u5426\u5c5e\u4e8e\u8be5\u7c7b\u578b\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">num = 100<\/p>\n<p>print(isinstance(num, int))  # \u8f93\u51fa\uff1aTrue<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4ee5\u4e0a\u4ee3\u7801\u7528\u4e8e\u68c0\u67e5<code>num<\/code>\u662f\u5426\u662f\u6574\u6570\u7c7b\u578b\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u68c0\u67e5\u5b50\u7c7b\u5173\u7cfb<\/strong><\/p>\n<\/p>\n<p><p><code>isinstance()<\/code>\u5728\u5904\u7406\u7ee7\u627f\u5173\u7cfb\u65f6\u5c24\u4e3a\u6709\u7528\uff0c\u53ef\u4ee5\u5224\u65ad\u4e00\u4e2a\u5bf9\u8c61\u662f\u5426\u4e3a\u67d0\u4e2a\u7c7b\u7684\u5b9e\u4f8b\u6216\u5b50\u7c7b\u7684\u5b9e\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">class Parent:<\/p>\n<p>    pass<\/p>\n<p>class Child(Parent):<\/p>\n<p>    pass<\/p>\n<p>obj = Child()<\/p>\n<p>print(isinstance(obj, Parent))  # \u8f93\u51fa\uff1aTrue<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u591a\u7c7b\u578b\u68c0\u67e5<\/strong><\/p>\n<\/p>\n<p><p><code>isinstance()<\/code>\u8fd8\u652f\u6301\u4f20\u5165\u4e00\u4e2a\u7c7b\u578b\u5143\u7ec4\uff0c\u4ee5\u4fbf\u68c0\u67e5\u5bf9\u8c61\u662f\u5426\u4e3a\u591a\u4e2a\u7c7b\u578b\u4e4b\u4e00\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">my_var = 3.14<\/p>\n<p>print(isinstance(my_var, (int, float, complex)))  # \u8f93\u51fa\uff1aTrue<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5bf9\u4e8e\u5904\u7406\u591a\u79cd\u53ef\u80fd\u7684\u6570\u636e\u7c7b\u578b\u65f6\u975e\u5e38\u65b9\u4fbf\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><p>\u56db\u3001\u901a\u8fc7<code>__class__<\/code>\u5c5e\u6027\u67e5\u770b\u7c7b\u578b  <\/p>\n<\/p>\n<p><p>\u9664\u4e86\u4f7f\u7528\u51fd\u6570\u5916\uff0cPython\u4e2d\u6bcf\u4e2a\u5bf9\u8c61\u90fd\u6709\u4e00\u4e2a<code>__class__<\/code>\u5c5e\u6027\uff0c\u53ef\u4ee5\u7528\u6765\u67e5\u770b\u5bf9\u8c61\u7684\u7c7b\u578b\u3002\u8fd9\u79cd\u65b9\u6cd5\u901a\u5e38\u7528\u4e8e\u9700\u8981\u83b7\u53d6\u66f4\u5e95\u5c42\u7684\u7c7b\u4fe1\u606f\u65f6\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u4f7f\u7528<code>__class__<\/code>\u5c5e\u6027<\/strong><\/p>\n<\/p>\n<p><p>\u76f4\u63a5\u8bbf\u95ee\u5bf9\u8c61\u7684<code>__class__<\/code>\u5c5e\u6027\uff0c\u53ef\u4ee5\u5f97\u5230\u5bf9\u8c61\u6240\u5c5e\u7684\u7c7b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">my_str = &quot;Hello&quot;<\/p>\n<p>print(my_str.__class__)  # \u8f93\u51fa\uff1a&lt;class &#39;str&#39;&gt;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u79cd\u65b9\u5f0f\u4e0e<code>type()<\/code>\u51fd\u6570\u7684\u8f93\u51fa\u7c7b\u4f3c\uff0c\u4f46<code>__class__<\/code>\u5c5e\u6027\u76f4\u63a5\u5c55\u793a\u4e86\u5bf9\u8c61\u7684\u7c7b\u4fe1\u606f\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9002\u7528\u4e8e\u81ea\u5b9a\u4e49\u7c7b<\/strong><\/p>\n<\/p>\n<p><p>\u5bf9\u4e8e\u81ea\u5b9a\u4e49\u7c7b\uff0c<code>__class__<\/code>\u5c5e\u6027\u540c\u6837\u9002\u7528\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">class CustomClass:<\/p>\n<p>    pass<\/p>\n<p>instance = CustomClass()<\/p>\n<p>print(instance.__class__)  # \u8f93\u51fa\uff1a&lt;class &#39;__main__.CustomClass&#39;&gt;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<p><p>\u4e94\u3001\u67e5\u770b\u7c7b\u578b\u7684\u5e94\u7528\u573a\u666f  <\/p>\n<\/p>\n<p><p>\u4e86\u89e3\u548c\u4f7f\u7528\u8fd9\u4e9b\u65b9\u6cd5\u6765\u67e5\u770b\u53d8\u91cf\u7c7b\u578b\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5728\u7f16\u7a0b\u8fc7\u7a0b\u4e2d\u8fdb\u884c\u66f4\u9ad8\u6548\u7684\u8c03\u8bd5\u548c\u7c7b\u578b\u68c0\u67e5\uff0c\u786e\u4fdd\u4ee3\u7801\u7684\u53ef\u9760\u6027\u548c\u53ef\u8bfb\u6027\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u8c03\u8bd5<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u8c03\u8bd5\u8fc7\u7a0b\u4e2d\uff0c\u4e86\u89e3\u53d8\u91cf\u7684\u7c7b\u578b\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u8fc5\u901f\u627e\u51fa\u4ee3\u7801\u4e2d\u7684\u9519\u8bef\u3002\u4f8b\u5982\uff0c\u5f53\u7a0b\u5e8f\u51fa\u73b0\u7c7b\u578b\u9519\u8bef\u65f6\uff0c\u901a\u8fc7\u68c0\u67e5\u53d8\u91cf\u7684\u5b9e\u9645\u7c7b\u578b\uff0c\u53ef\u4ee5\u66f4\u5feb\u5730\u627e\u5230\u95ee\u9898\u6240\u5728\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7c7b\u578b\u68c0\u67e5<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u7f16\u5199\u51fd\u6570\u6216\u7c7b\u65f6\uff0c\u786e\u4fdd\u8f93\u5165\u53c2\u6570\u548c\u8fd4\u56de\u503c\u7684\u7c7b\u578b\u6b63\u786e\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u4f7f\u7528<code>isinstance()<\/code>\u51fd\u6570\u53ef\u4ee5\u8fdb\u884c\u7c7b\u578b\u68c0\u67e5\uff0c\u786e\u4fdd\u7a0b\u5e8f\u6309\u9884\u671f\u8fd0\u884c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u589e\u5f3a\u4ee3\u7801\u53ef\u8bfb\u6027<\/strong><\/p>\n<\/p>\n<p><p>\u6e05\u6670\u7684\u7c7b\u578b\u4fe1\u606f\u53ef\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\uff0c\u4f7f\u5176\u4ed6\u5f00\u53d1\u8005\uff08\u5305\u62ec\u672a\u6765\u7684\u81ea\u5df1\uff09\u66f4\u5bb9\u6613\u7406\u89e3\u4ee3\u7801\u7684\u610f\u56fe\u548c\u903b\u8f91\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><p>\u516d\u3001\u603b\u7ed3  <\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\u67e5\u770b\u53d8\u91cf\u7c7b\u578b\u7684\u65b9\u6cd5\u591a\u79cd\u591a\u6837\uff0c<code>type()<\/code>\u3001<code>isinstance()<\/code>\u3001<code>__class__<\/code>\u5c5e\u6027\u5404\u6709\u5176\u4f18\u7f3a\u70b9\u548c\u9002\u7528\u573a\u666f\u3002<strong><code>type()<\/code>\u51fd\u6570\u7b80\u5355\u6613\u7528\uff0c\u9002\u5408\u5feb\u901f\u67e5\u770b\u7c7b\u578b\uff1b<code>isinstance()<\/code>\u51fd\u6570\u7075\u6d3b\u6027\u9ad8\uff0c\u9002\u7528\u4e8e\u590d\u6742\u7684\u7c7b\u578b\u68c0\u67e5\uff1b<code>__class__<\/code>\u5c5e\u6027\u5219\u5728\u9700\u8981\u76f4\u63a5\u8bbf\u95ee\u7c7b\u4fe1\u606f\u65f6\u5c24\u4e3a\u65b9\u4fbf\u3002<\/strong>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6839\u636e\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\uff0c\u4e0d\u4ec5\u53ef\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7684\u5065\u58ee\u6027\uff0c\u8fd8\u80fd\u589e\u5f3a\u53ef\u8bfb\u6027\u548c\u7ef4\u62a4\u6027\u3002\u901a\u8fc7\u638c\u63e1\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u66f4\u6709\u6548\u5730\u8fdb\u884c\u8c03\u8bd5\u3001\u7c7b\u578b\u68c0\u67e5\u4ee5\u53ca\u4ee3\u7801\u4f18\u5316\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u67e5\u770b\u4e00\u4e2a\u53d8\u91cf\u7684\u7c7b\u578b\uff1f<\/strong><br \/>\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u7684<code>type()<\/code>\u51fd\u6570\u6765\u67e5\u770b\u4e00\u4e2a\u53d8\u91cf\u7684\u7c7b\u578b\u3002\u4f8b\u5982\uff0c\u4f7f\u7528<code>type(variable_name)<\/code>\u53ef\u4ee5\u8fd4\u56de\u8be5\u53d8\u91cf\u7684\u7c7b\u578b\u3002\u5728Jupyter Notebook\u6216\u4ea4\u4e92\u5f0fPython\u73af\u5883\u4e2d\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u975e\u5e38\u65b9\u4fbf\u3002<\/p>\n<p><strong>\u5982\u4f55\u68c0\u67e5\u4e00\u4e2a\u5bf9\u8c61\u662f\u5426\u662f\u7279\u5b9a\u7c7b\u578b\uff1f<\/strong><br \/>\u4f7f\u7528<code>isinstance()<\/code>\u51fd\u6570\u53ef\u4ee5\u68c0\u67e5\u4e00\u4e2a\u5bf9\u8c61\u662f\u5426\u5c5e\u4e8e\u67d0\u4e2a\u7279\u5b9a\u7684\u7c7b\u578b\u3002\u8bed\u6cd5\u4e3a<code>isinstance(object, type)<\/code>\uff0c\u5982\u679c\u5bf9\u8c61\u7684\u7c7b\u578b\u4e0e\u6307\u5b9a\u7684\u7c7b\u578b\u5339\u914d\uff0c\u5219\u8fd4\u56deTrue\u3002\u8fd9\u5728\u8fdb\u884c\u7c7b\u578b\u5224\u65ad\u548c\u6761\u4ef6\u5904\u7406\u65f6\u975e\u5e38\u6709\u7528\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5982\u4f55\u67e5\u770b\u6570\u636e\u7ed3\u6784\u7684\u7c7b\u578b\uff0c\u6bd4\u5982\u5217\u8868\u6216\u5b57\u5178\uff1f<\/strong><br \/>\u4e0e\u67e5\u770b\u666e\u901a\u53d8\u91cf\u7684\u7c7b\u578b\u76f8\u540c\uff0c\u53ef\u4ee5\u4f7f\u7528<code>type()<\/code>\u51fd\u6570\u6765\u67e5\u770b\u6570\u636e\u7ed3\u6784\u7684\u7c7b\u578b\u3002\u4f8b\u5982\uff0c\u5bf9\u4e8e\u5217\u8868\uff0c\u53ef\u4ee5\u4f7f\u7528<code>type(my_list)<\/code>\u6765\u83b7\u53d6\u5176\u7c7b\u578b\uff0c\u8fd4\u56de\u7ed3\u679c\u4f1a\u663e\u793a\u4e3a<code>&lt;class &#39;list&#39;&gt;<\/code>\u3002\u5bf9\u4e8e\u5b57\u5178\uff0c\u4f7f\u7528<code>type(my_dict)<\/code>\uff0c\u7ed3\u679c\u5219\u4f1a\u663e\u793a\u4e3a<code>&lt;class &#39;dict&#39;&gt;<\/code>\u3002\u8fd9\u6837\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u7406\u89e3\u548c\u5904\u7406\u4e0d\u540c\u7684\u6570\u636e\u7ed3\u6784\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u4e00\u3001\u67e5\u770bPython\u4e2d\u53d8\u91cf\u7c7b\u578b\u7684\u65b9\u6cd5 \u5728Python\u4e2d\u67e5\u770b\u53d8\u91cf\u7c7b\u578b\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u4f7f\u7528\u5185\u7f6e\u51fd\u6570type()\u3001\u4f7f\u7528 [&hellip;]","protected":false},"author":3,"featured_media":960699,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/960693"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=960693"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/960693\/revisions"}],"predecessor-version":[{"id":960700,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/960693\/revisions\/960700"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/960699"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=960693"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=960693"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=960693"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}