{"id":60,"date":"2026-08-05T23:24:47","date_gmt":"2026-08-05T15:24:47","guid":{"rendered":"https:\/\/ltrainyard.icu\/?p=60"},"modified":"2026-08-06T00:41:59","modified_gmt":"2026-08-05T16:41:59","slug":"day-2-%e6%95%b0%e6%8d%ae%e7%b1%bb%e5%9e%8b%ef%bc%9aint-float-str-bool-%e4%b8%8e%e7%b1%bb%e5%9e%8b%e8%bd%ac%e6%8d%a2","status":"publish","type":"post","link":"https:\/\/ltrainyard.icu\/index.php\/2026\/08\/05\/day-2-%e6%95%b0%e6%8d%ae%e7%b1%bb%e5%9e%8b%ef%bc%9aint-float-str-bool-%e4%b8%8e%e7%b1%bb%e5%9e%8b%e8%bd%ac%e6%8d%a2\/","title":{"rendered":"| Day 2 | \u6570\u636e\u7c7b\u578b\uff1aint \/ float \/ str \/ bool \u4e0e\u7c7b\u578b\u8f6c\u6362 |"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">1 \u6570\u636e\u7c7b\u578b\uff1aint \/ float \/ str \/ bool<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u662f\u4ec0\u4e48\uff1f\u4e3a\u4ec0\u4e48\u5b66\uff1f<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u6570\u636e\u7c7b\u578b<\/strong>\uff08data type\uff09\u5c31\u662f\u300c\u6570\u636e\u7684\u79cd\u7c7b\u300d\u3002\u540c\u4e00\u4e2a\u6570\u5b57 <code>18<\/code>\uff0c\u662f\u6574\u6570\uff1b<code>\"18\"<\/code> \u5e26\u5f15\u53f7\uff0c\u5c31\u662f\u5b57\u7b26\u4e32\u2014\u2014\u770b\u8d77\u6765\u4e00\u6837\uff0c\u6027\u8d28\u5b8c\u5168\u4e0d\u540c\u3002\u4e3a\u4ec0\u4e48\u96f6\u57fa\u7840\u5fc5\u5b66\uff1f\u56e0\u4e3a\u7c7b\u578b\u51b3\u5b9a\u4e86<strong>\u80fd\u5bf9\u6570\u636e\u505a\u4ec0\u4e48<\/strong>\uff1a\u6570\u5b57\u80fd\u7b97\u6570\uff0c\u6587\u672c\u80fd\u62fc\u63a5\uff0c\u641e\u6df7\u4e86\u7a0b\u5e8f\u7acb\u523b\u62a5\u9519\u3002\u5b66\u4f1a\u300c\u4e00\u773c\u5206\u8fa8\u7c7b\u578b\u300d\uff0c\u662f\u5199\u5bf9\u4ee3\u7801\u7684\u7b2c\u4e00\u9053\u95e8\u69db\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u56db\u79cd\u57fa\u672c\u7c7b\u578b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u7c7b\u578b<\/th><th>\u540d\u79f0<\/th><th>\u4f8b\u5b50<\/th><th>\u8bf4\u660e<\/th><\/tr><\/thead><tbody><tr><td>\u6574\u6570<\/td><td>int<\/td><td><code>18<\/code>\u3001<code>-3<\/code>\u3001<code>100<\/code><\/td><td>\u6ca1\u6709\u5c0f\u6570\u70b9\u7684\u6570\u5b57<\/td><\/tr><tr><td>\u5c0f\u6570<\/td><td>float<\/td><td><code>3.14<\/code>\u3001<code>1.75<\/code><\/td><td>\u6709\u5c0f\u6570\u70b9\u7684\u6570\u5b57<\/td><\/tr><tr><td>\u5b57\u7b26\u4e32<\/td><td>str<\/td><td><code>\"\u4f60\u597d\"<\/code>\u3001<code>'Python'<\/code><\/td><td>\u7528\u5f15\u53f7\u5305\u8d77\u6765\u7684\u6587\u672c<\/td><\/tr><tr><td>\u5e03\u5c14<\/td><td>bool<\/td><td><code>True<\/code>\u3001<code>False<\/code><\/td><td>\u53ea\u6709\u771f\u548c\u5047\u4e24\u79cd<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u5e95\u5c42\u539f\u7406<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7535\u8111\u5b58\u50a8\u6570\u636e\u65f6\uff0c\u5fc5\u987b\u77e5\u9053\u8fd9\u5757\u6570\u636e\u662f\u300c\u6570\u5b57\u300d\u8fd8\u662f\u300c\u6587\u672c\u300d\uff0c\u56e0\u4e3a\u5b83\u4eec\u5728\u5185\u5b58\u91cc\u7684<strong>\u5b58\u50a8\u65b9\u5f0f\u5b8c\u5168\u4e0d\u540c<\/strong>\uff1a\u6570\u5b57\u6309\u4e8c\u8fdb\u5236\u6570\u503c\u5b58\uff0c\u6587\u672c\u6309\u7f16\u7801\u8868\uff08\u6bcf\u4e2a\u5b57\u7b26\u5bf9\u5e94\u4e00\u4e2a\u7f16\u53f7\uff09\u5b58\u3002Python \u662f<strong>\u52a8\u6001\u7c7b\u578b<\/strong>\u8bed\u8a00\u2014\u2014\u4f60\u4e0d\u7528\u58f0\u660e\u53d8\u91cf\u662f\u4ec0\u4e48\u7c7b\u578b\uff0cPython \u4f1a\u6839\u636e\u4f60\u7ed9\u7684\u503c\u81ea\u52a8\u5224\u65ad\uff0c\u5e76\u7262\u7262\u8bb0\u4f4f\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u672f\u8bed\u5c0f\u8bcd\u5178\uff1a<strong>\u52a8\u6001\u7c7b\u578b<\/strong>\uff08dynamic typing\uff09\u5c31\u662f\u300cPython \u81ea\u5df1\u770b\u4eba\u4e0b\u83dc\u789f\u300d\uff1a\u4f60\u8d4b <code>18<\/code> \u5b83\u5c31\u662f\u6574\u6570\uff0c\u4f60\u8d4b <code>\"18\"<\/code> \u5b83\u5c31\u662f\u5b57\u7b26\u4e32\uff0c\u4e0d\u9700\u8981\u4f60\u63d0\u524d\u58f0\u660e\u3002<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u751f\u6d3b\u7c7b\u6bd4<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7c7b\u578b\u5c31\u50cf<strong>\u5feb\u9012\u7bb1\u4e0a\u7684\u5206\u7c7b\u6807\u7b7e<\/strong>\uff1a\u6807\u7740\u300c\u6613\u788e\u54c1\u300d\u7684\u7bb1\u5b50\uff08\u6570\u5b57\uff09\u8981\u5c0f\u5fc3\u642c\u8fd0\uff0c\u6807\u7740\u300c\u4e66\u7c4d\u300d\u7684\u7bb1\u5b50\uff08\u5b57\u7b26\u4e32\uff09\u8981\u6309\u4e66\u540d\u6574\u7406\u3002\u6807\u7b7e\u4e0d\u540c\uff0c\u5904\u7406\u65b9\u5f0f\u5c31\u4e0d\u540c\u3002Python \u770b\u5230 <code>18<\/code> \u548c <code>\"18\"<\/code>\uff0c\u5c31\u50cf\u770b\u5230\u4e24\u4e2a\u6807\u7b7e\u4e0d\u540c\u7684\u7bb1\u5b50\u2014\u2014\u4e00\u4e2a\u4f1a\u7b97\u6570\uff0c\u4e00\u4e2a\u53ea\u80fd\u5f53\u6587\u5b57\u770b\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u6ce8\u610f\u4e8b\u9879\u603b\u7ed3<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1 <strong>\u5b57\u7b26\u4e32\u5fc5\u987b\u52a0\u5f15\u53f7<\/strong>\uff1a<code>\"123\"<\/code> \u662f\u6587\u672c\uff0c\u53ea\u8d1f\u8d23\u663e\u793a\uff1b<code>123<\/code> \u662f\u6570\u5b57\uff0c\u80fd\u53c2\u4e0e\u8fd0\u7b97\u3002\u4e0d\u52a0\u5f15\u53f7\u4f1a\u88ab\u5f53\u6210\u53d8\u91cf\u6216\u62a5\u9519\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2 <strong>\u5e03\u5c14\u503c\u9996\u5b57\u6bcd\u5927\u5199<\/strong>\uff1a<code>True<\/code> \/ <code>False<\/code> \u9996\u5b57\u6bcd\u5fc5\u987b\u5927\u5199\uff0c\u5199\u6210 <code>true<\/code> \u4f1a\u62a5 <code>NameError<\/code>\uff08Python \u533a\u5206\u5927\u5c0f\u5199\uff09\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3 <strong>\u7c7b\u578b\u51b3\u5b9a\u884c\u4e3a<\/strong>\uff1a\u540c\u4e00\u4e2a\u52a0\u53f7\uff0c\u5b57\u7b26\u4e32\u62fc\u63a5\u3001\u6570\u5b57\u76f8\u52a0\uff0c\u7ed3\u679c\u5b8c\u5168\u4e0d\u540c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>print(\"3\" + \"5\")    # \u5b57\u7b26\u4e32\u62fc\u63a5\uff1a35\nprint(3 + 5)        # \u6570\u5b57\u76f8\u52a0\uff1a8\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u6613\u9519\u70b9<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u9519\u8bef\u5199\u6cd5\uff1a<code>age = 18\u5c81<\/code> \u2192 \u95ee\u9898\uff1a<code>18\u5c81<\/code> \u65e2\u4e0d\u662f\u5408\u6cd5\u6570\u5b57\u4e5f\u4e0d\u662f\u5408\u6cd5\u53d8\u91cf\uff0c\u62a5 <code>SyntaxError<\/code> \u2192 \u6b63\u786e\u5199\u6cd5\uff1a\u6570\u5b57\u548c\u6587\u5b57\u5206\u5f00\u5b58\uff1a<code>age = 18<\/code>\u3001<code>unit = \"\u5c81\"<\/code>\u3002<\/li>\n\n\n\n<li>\u9519\u8bef\u5199\u6cd5\uff1a<code>is_student = true<\/code> \u2192 \u95ee\u9898\uff1aPython \u53ea\u8ba4 <code>True<\/code>\/<code>False<\/code>\uff0c\u62a5 <code>NameError<\/code> \u2192 \u6b63\u786e\u5199\u6cd5\uff1a<code>is_student = True<\/code>\u3002<\/li>\n\n\n\n<li>\u9519\u8bef\u5199\u6cd5\uff1a<code>print(\"123\" + 1)<\/code> \u2192 \u95ee\u9898\uff1a\u5b57\u7b26\u4e32\u548c\u6570\u5b57\u4e0d\u80fd\u76f4\u63a5\u76f8\u52a0\uff0c\u62a5 <code>TypeError<\/code> \u2192 \u6b63\u786e\u5199\u6cd5\uff1a\u5148\u8f6c\u6362\u7c7b\u578b\uff0c\u6216 <code>print(123 + 1)<\/code>\u3002<\/li>\n\n\n\n<li>\u9519\u8bef\u5199\u6cd5\uff1a\u628a\u5c0f\u6570\u8d4b\u7ed9\u53d8\u91cf\u5c31\u4ee5\u4e3a\u5b83\u662f\u300c\u6574\u6570\u300d \u2192 \u95ee\u9898\uff1a<code>1.75<\/code> \u662f float\uff0c<code>1<\/code> \u662f int\uff0c\u7c7b\u578b\u4e0d\u540c \u2192 \u6b63\u786e\u5199\u6cd5\uff1a\u6709\u5c0f\u6570\u70b9\u5c31\u662f float\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u8bb0\u5fc6\u53e3\u8bc0<\/strong>\uff1a\u6574\u6570\u5b57\u7b26\u5e03\u5c14\u6d6e\uff0c\u56db\u79cd\u7c7b\u578b\u8981\u8bb0\u4f4f\uff1b\u5e26\u5f15\u53f7\u7684\u662f\u6587\u672c\uff0c\u4e0d\u5e26\u5f15\u53f7\u662f\u6570\u5b57\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2 type() \u2014\u2014 \u67e5\u770b\u6570\u636e\u7c7b\u578b\u7684\u300c\u8eab\u4efd\u8bc1\u300d<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u662f\u4ec0\u4e48\uff1f\u4e3a\u4ec0\u4e48\u5b66\uff1f<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>type()<\/code> \u51fd\u6570\u80fd\u544a\u8bc9\u4f60\u4e00\u4e2a\u6570\u636e\u662f\u4ec0\u4e48\u7c7b\u578b\uff0c\u8fd4\u56de\u503c\u957f\u5f97\u50cf <code>&lt;class 'int'&gt;<\/code>\u3002\u4e3a\u4ec0\u4e48\u5b66\uff1f\u56e0\u4e3a<strong>\u731c\u7c7b\u578b\u6700\u5bb9\u6613\u51fa\u9519<\/strong>\u2014\u2014\u5c24\u5176\u662f <code>input()<\/code> \u62ff\u5230\u7684\u6570\u636e\uff0c\u770b\u7740\u50cf\u6570\u5b57\u5176\u5b9e\u662f\u5b57\u7b26\u4e32\u3002\u9047\u5230\u4e0d\u786e\u5b9a\u7684\u7c7b\u578b\uff0c\u968f\u624b <code>type()<\/code> \u4e00\u770b\u4fbf\u77e5\uff0c\u8fd9\u662f\u6392\u67e5 bug \u7684\u300c\u9a8c\u949e\u673a\u300d\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u5e95\u5c42\u539f\u7406<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Python \u91cc\u4e07\u7269\u7686<strong>\u5bf9\u8c61<\/strong>\uff08object\uff09\uff0c\u6bcf\u4e2a\u5bf9\u8c61\u90fd\u81ea\u5e26\u4e00\u4e2a\u300c\u7c7b\u578b\u6807\u7b7e\u300d\u3002<code>type()<\/code> \u505a\u7684\u5c31\u662f\u628a\u8fd9\u4e2a\u6807\u7b7e\u62ff\u51fa\u6765\u7ed9\u4f60\u770b\u3002<code>&lt;class 'int'&gt;<\/code> \u7684\u610f\u601d\u662f\u300c\u8fd9\u662f int \u8fd9\u4e2a\u7c7b\uff08\u7c7b\u522b\uff09\u7684\u5b9e\u4f8b\u300d\u2014\u2014<code>class<\/code> \u5728\u8fd9\u91cc\u5c31\u662f\u300c\u7c7b\u522b\u300d\u7684\u610f\u601d\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u672f\u8bed\u5c0f\u8bcd\u5178\uff1a<strong>\u5bf9\u8c61<\/strong>\uff08object\uff09\u53ef\u4ee5\u7b80\u5355\u7406\u89e3\u4e3a\u300c\u5185\u5b58\u91cc\u7684\u4e00\u5768\u6709\u7c7b\u578b\u7684\u6570\u636e\u300d\u3002<strong>\u7c7b<\/strong>\uff08class\uff09\u5c31\u662f\u300c\u7c7b\u522b\u300d\uff0c\u662f\u5bf9\u8c61\u7684\u6a21\u677f\u3002<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u751f\u6d3b\u7c7b\u6bd4<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>type()<\/code> \u50cf<strong>\u8d85\u5e02\u6536\u94f6\u53f0\u7684\u626b\u7801\u5668<\/strong>\uff1a\u628a\u5546\u54c1\uff08\u6570\u636e\uff09\u5f80\u4e0a\u4e00\u626b\uff0c\u5c4f\u5e55\u4e0a\u7acb\u523b\u663e\u793a\u8fd9\u662f\u300c\u996e\u6599\u300d\u8fd8\u662f\u300c\u96f6\u98df\u300d\uff08\u7c7b\u578b\uff09\u3002\u4f60\u4e0d\u77e5\u9053\u624b\u91cc\u62ff\u7684\u662f\u4ec0\u4e48\uff0c\u626b\u4e00\u4e0b\u5c31\u77e5\u9053\u4e86\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u6ce8\u610f\u4e8b\u9879\u603b\u7ed3<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1 <strong>\u57fa\u672c\u7528\u6cd5<\/strong>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>print(type(18))        # &lt;class 'int'&gt;\nprint(type(3.14))      # &lt;class 'float'&gt;\nprint(type(\"Python\"))  # &lt;class 'str'&gt;\nprint(type(True))      # &lt;class 'bool'&gt;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">2 <strong>\u53d8\u91cf\u6ca1\u6709\u56fa\u5b9a\u7c7b\u578b<\/strong>\uff1a\u7c7b\u578b\u7531\u5f53\u524d\u5b58\u7684\u503c\u51b3\u5b9a\u3002<code>price = 9.9<\/code> \u662f float\uff0c\u91cd\u65b0\u8d4b <code>price = \"9.9\"<\/code>\uff08\u5e26\u5f15\u53f7\uff09\u5c31\u53d8\u6210 str\u2014\u2014\u8fd9\u5c31\u662f\u300c\u52a8\u6001\u7c7b\u578b\u300d\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3 <strong>\u7c7b\u578b\u51b3\u5b9a\u884c\u4e3a<\/strong>\uff1a<code>\"3\" + \"5\"<\/code> \u662f\u6587\u672c\u62fc\u63a5\u5f97 <code>35<\/code>\uff0c<code>3 + 5<\/code> \u662f\u6570\u5b66\u52a0\u6cd5\u5f97 <code>8<\/code>\u3002\u540c\u4e00\u4e2a\u7b26\u53f7\uff0c\u7c7b\u578b\u4e0d\u540c\u884c\u4e3a\u5c31\u4e0d\u540c\u2014\u2014\u8fd9\u662f\u5f88\u591a\u62a5\u9519\u7684\u6839\u6e90\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u6613\u9519\u70b9<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u9519\u8bef\u5199\u6cd5\uff1a<code>print(type 18)<\/code> \u2192 \u95ee\u9898\uff1a\u8c03\u7528\u51fd\u6570\u5fc5\u987b\u5e26\u62ec\u53f7\uff0c\u62a5 <code>SyntaxError<\/code> \u2192 \u6b63\u786e\u5199\u6cd5\uff1a<code>print(type(18))<\/code>\u3002<\/li>\n\n\n\n<li>\u9519\u8bef\u5199\u6cd5\uff1a<code>type(x) == \"int\"<\/code> \u2192 \u95ee\u9898\uff1a<code>type(x)<\/code> \u8fd4\u56de\u7684\u662f <code>&lt;class 'int'><\/code> \u5bf9\u8c61\uff0c\u4e0d\u7b49\u4e8e\u5b57\u7b26\u4e32 <code>\"int\"<\/code>\uff0c\u6c38\u8fdc False \u2192 \u6b63\u786e\u5199\u6cd5\uff1a<code>type(x) == int<\/code>\uff08\u4e0d\u5e26\u5f15\u53f7\uff09\u3002<\/li>\n\n\n\n<li>\u9519\u8bef\u5199\u6cd5\uff1a<code>print(type(\"18\"))<\/code> \u5374\u4ee5\u4e3a\u8f93\u51fa int \u2192 \u95ee\u9898\uff1a\u5e26\u5f15\u53f7\u5c31\u662f\u5b57\u7b26\u4e32 \u2192 \u6b63\u786e\u5199\u6cd5\uff1a\u6709\u5f15\u53f7\u662f str\uff0c\u6ca1\u5f15\u53f7\u624d\u662f\u6570\u5b57\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u8bb0\u5fc6\u53e3\u8bc0<\/strong>\uff1a\u7c7b\u578b\u4e0d\u660e\u627e type\uff0c\u62ec\u53f7\u91cc\u9762\u653e\u6570\u636e\uff1b\u5e26\u5f15\u53f7\u662f\u5b57\u7b26\u4e32\uff0c\u8fd9\u662f\u6700\u5bb9\u6613\u8bb0\u9519\u7684\u4e8b\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3 \u7c7b\u578b\u8f6c\u6362 \u2014\u2014 \u8ba9\u4e0d\u540c\u7c7b\u578b\u300c\u6253\u4ea4\u9053\u300d<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u662f\u4ec0\u4e48\uff1f\u4e3a\u4ec0\u4e48\u5b66\uff1f<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u7c7b\u578b\u8f6c\u6362<\/strong>\uff08type conversion\uff09\u5c31\u662f\u7528\u4e00\u4e2a\u51fd\u6570\u628a\u6570\u636e\u4ece\u4e00\u79cd\u7c7b\u578b\u53d8\u6210\u53e6\u4e00\u79cd\uff1a<code>int()<\/code> \u8f6c\u6574\u6570\u3001<code>float()<\/code> \u8f6c\u5c0f\u6570\u3001<code>str()<\/code> \u8f6c\u5b57\u7b26\u4e32\u3002\u4e3a\u4ec0\u4e48\u5fc5\u5b66\uff1f\u56e0\u4e3a\u7a0b\u5e8f\u91cc\u6700\u5e38\u89c1\u7684\u573a\u666f\u662f\u2014\u2014<code>input()<\/code> \u62ff\u5230\u7684\u662f\u5b57\u7b26\u4e32\uff0c\u53ef\u4f60\u8981\u505a\u6570\u5b66\u8ba1\u7b97\uff1b<code>print()<\/code> \u62fc\u63a5\u53c8\u8981\u6c42\u5b57\u7b26\u4e32\u3002\u4e0d\u4f1a\u8f6c\u6362\uff0c\u7a0b\u5e8f\u5bf8\u6b65\u96be\u884c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u5e95\u5c42\u539f\u7406<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8f6c\u6362\u4e0d\u662f\u300c\u628a\u6807\u7b7e\u6495\u4e86\u6362\u4e00\u5f20\u300d\uff0c\u800c\u662f<strong>\u771f\u6b63\u5730\u91cd\u65b0\u89e3\u91ca\u6570\u636e<\/strong>\uff1a<code>int(\"100\")<\/code> \u4f1a\u8bfb\u53d6\u6587\u672c <code>100<\/code>\uff0c\u6309\u6570\u5b57\u89c4\u5219\u89e3\u6790\u51fa\u6570\u503c 100\uff0c\u5b58\u6210\u4e00\u4e2a\u65b0\u7684\u6574\u6570\u5bf9\u8c61\u3002\u5982\u679c\u6587\u672c\u5185\u5bb9\u4e0d\u662f\u5408\u6cd5\u6570\u5b57\uff08\u5982 <code>\"abc\"<\/code>\uff09\uff0c\u89e3\u6790\u5931\u8d25\uff0cPython \u5c31\u629b <code>ValueError<\/code>\u3002<code>str(42)<\/code> \u5219\u53cd\u8fc7\u6765\uff1a\u628a\u6570\u503c 42 \u8f6c\u6362\u6210\u6587\u672c <code>\"42\"<\/code>\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u672f\u8bed\u5c0f\u8bcd\u5178\uff1a<strong>ValueError<\/strong> \u662f\u300c\u503c\u9519\u8bef\u300d\u2014\u2014\u6570\u636e\u672c\u8eab\u6ca1\u95ee\u9898\uff0c\u4f46\u5185\u5bb9\u4e0d\u7b26\u5408\u8981\u6c42\u3002\u6bd4\u5982\u8ba9 Python \u628a <code>\"abc\"<\/code> \u5f53\u6570\u5b57\u8bfb\uff0c\u5b83\u8bfb\u4e0d\u51fa\u6765\u5c31\u62a5\u8fd9\u4e2a\u9519\u3002<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u751f\u6d3b\u7c7b\u6bd4<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7c7b\u578b\u8f6c\u6362\u50cf<strong>\u8d27\u5e01\u5151\u6362<\/strong>\uff1a\u4f60\u6709 100 \u7f8e\u5143\uff08\u6570\u5b57\uff09\uff0c\u60f3\u5728\u4e2d\u56fd\u82b1\uff0c\u5f97\u53bb\u94f6\u884c\u6362\u6210\u4eba\u6c11\u5e01\u3002\u5151\u6362\u6709\u6c47\u7387\uff08\u8f6c\u6362\u89c4\u5219\uff09\uff0c\u7f8e\u5143\u6362\u4eba\u6c11\u5e01\u5f88\u987a\u5229\uff1b\u4f46\u4f60\u62ff\u7740\u4e00\u5f20\u5199\u7740\u300cabc\u300d\u7684\u7eb8\u6761\uff08\u4e0d\u662f\u94b1\uff09\u53bb\u5151\u6362\uff0c\u94f6\u884c\uff08Python\uff09\u53ea\u80fd\u62d2\u7edd\u2014\u2014\u8fd9\u5c31\u662f <code>ValueError<\/code>\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u6ce8\u610f\u4e8b\u9879\u603b\u7ed3<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1 <strong>\u4e09\u79cd\u57fa\u672c\u8f6c\u6362<\/strong>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>print(int(\"100\"))      # \u5b57\u7b26\u4e32 \u2192 \u6574\u6570\uff1a100\nprint(float(\"3.14\"))   # \u5b57\u7b26\u4e32 \u2192 \u5c0f\u6570\uff1a3.14\nprint(str(42))         # \u6574\u6570 \u2192 \u5b57\u7b26\u4e32\uff1a\"42\"\nprint(int(3.9))        # \u5c0f\u6570 \u2192 \u6574\u6570\uff1a3\uff08\u76f4\u63a5\u780d\u6389\u5c0f\u6570\u90e8\u5206\uff0c\u4e0d\u56db\u820d\u4e94\u5165\uff09\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">2 <strong>\u8f6c\u6362\u540e\u624d\u80fd\u771f\u6b63\u8ba1\u7b97<\/strong>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>a = \"7\"\nb = \"8\"\nprint(a + b)            # \u5b57\u7b26\u4e32\u62fc\u63a5\uff1a\"78\"\nprint(int(a) + int(b))  # \u8f6c\u6210\u6574\u6570\u518d\u76f8\u52a0\uff1a15\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">3 <strong>\u8f6c\u4e0d\u52a8\u7684\u6570\u636e\u4f1a\u62a5\u9519<\/strong>\uff1a<code>int(\"abc\")<\/code>\u3001<code>float(\"1.2.3\")<\/code> \u90fd\u4e0d\u662f\u5408\u6cd5\u6570\u5b57\u5199\u6cd5\uff0c\u4f1a\u62a5 <code>ValueError<\/code>\u3002\u8f6c\u6362\u524d\u5148\u786e\u8ba4\u6587\u672c\u5185\u5bb9\u957f\u5f97\u50cf\u6570\u5b57\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u6613\u9519\u70b9<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u9519\u8bef\u5199\u6cd5\uff1a<code>int(\"3.14\")<\/code> \u2192 \u95ee\u9898\uff1a\u6587\u672c\u91cc\u6709\u5c0f\u6570\u70b9\uff0c<code>int()<\/code> \u4e0d\u8ba4\uff0c\u62a5 <code>ValueError<\/code> \u2192 \u6b63\u786e\u5199\u6cd5\uff1a\u5148\u8f6c float\uff1a<code>float(\"3.14\")<\/code>\uff0c\u9700\u8981\u6574\u6570\u518d <code>int(3.14)<\/code>\u3002<\/li>\n\n\n\n<li>\u9519\u8bef\u5199\u6cd5\uff1a<code>float(\"abc\")<\/code> \u2192 \u95ee\u9898\uff1a\u8bfb\u4e0d\u51fa\u6570\u5b57\uff0c\u62a5 <code>ValueError<\/code> \u2192 \u6b63\u786e\u5199\u6cd5\uff1a\u8f6c\u6362\u524d\u7528 <code>isdigit()<\/code> \u68c0\u67e5\u6216 <code>try<\/code> \u5904\u7406\uff08Day 9 \u5b66\uff09\u3002<\/li>\n\n\n\n<li>\u9519\u8bef\u5199\u6cd5\uff1a<code>str(42) + 1<\/code> \u2192 \u95ee\u9898\uff1a\u8f6c\u5b8c\u7684 <code>\"42\"<\/code> \u662f\u5b57\u7b26\u4e32\uff0c\u8fd8\u662f\u4e0d\u80fd\u548c\u6570\u5b57\u76f8\u52a0 \u2192 \u6b63\u786e\u5199\u6cd5\uff1a\u60f3\u7b97\u5c31\u8f6c\u6570\u5b57\uff1a<code>int(\"42\") + 1<\/code>\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u8bb0\u5fc6\u53e3\u8bc0<\/strong>\uff1a\u8f6c\u6574\u6570\u7528 int\uff0c\u8f6c\u5c0f\u6570\u7528 float\uff0c\u8f6c\u6587\u672c\u7528 str\uff1b\u5185\u5bb9\u4e0d\u50cf\u6570\uff0c\u8f6c\u6362\u5fc5\u62a5\u9519\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4 input() \u2014\u2014 \u8ba9\u7a0b\u5e8f\u300c\u542c\u300d\u7528\u6237\u8bf4\u8bdd<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u662f\u4ec0\u4e48\uff1f\u4e3a\u4ec0\u4e48\u5b66\uff1f<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>input()<\/code> \u51fd\u6570\u4f1a\u5728\u5c4f\u5e55\u4e0a\u663e\u793a\u63d0\u793a\u6587\u5b57\uff0c\u7136\u540e<strong>\u7b49\u5f85\u7528\u6237\u5728\u7ec8\u7aef\u91cc\u8f93\u5165\u5185\u5bb9\uff0c\u56de\u8f66\u540e\u628a\u8f93\u5165\u7684\u5185\u5bb9\u4f5c\u4e3a\u5b57\u7b26\u4e32\u8fd4\u56de<\/strong>\u3002\u4e3a\u4ec0\u4e48\u5fc5\u5b66\uff1f\u56e0\u4e3a\u5199\u6b7b\u7684\u7a0b\u5e8f\u53ea\u80fd\u8fd0\u884c\u4e00\u6b21\uff0c\u4f1a\u300c\u542c\u300d\u7528\u6237\u8bf4\u8bdd\u7684\u7a0b\u5e8f\u624d\u6709\u771f\u6b63\u7684\u5b9e\u7528\u4ef7\u503c\u2014\u2014\u8ba1\u7b97\u5668\u96cf\u5f62\u5c31\u9760\u5b83\u5b9e\u73b0\u4eba\u673a\u5bf9\u8bdd\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u5e95\u5c42\u539f\u7406<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>input()<\/code> \u505a\u7684\u4e8b\uff1a\u2460 \u628a\u63d0\u793a\u6587\u5b57\u6253\u5370\u5230\u5c4f\u5e55\uff08\u4e0d\u6362\u884c\uff09\uff1b\u2461 \u7a0b\u5e8f\u6682\u505c\uff0c\u7b49\u5f85\u7528\u6237\u5728\u7ec8\u7aef\u8f93\u5165\uff1b\u2462 \u7528\u6237\u6309\u4e0b\u56de\u8f66\u540e\uff0c\u628a\u8f93\u5165\u5185\u5bb9\uff08<strong>\u6c38\u8fdc\u4f5c\u4e3a\u5b57\u7b26\u4e32<\/strong>\uff09\u8fd4\u56de\u7ed9\u7a0b\u5e8f\u3002\u6ce8\u610f\uff1a\u7528\u6237\u8f93\u5165 <code>10<\/code>\uff0c\u5b83\u8fd4\u56de\u7684\u662f\u5b57\u7b26\u4e32 <code>\"10\"<\/code>\uff0c\u4e0d\u662f\u6570\u5b57 10\u2014\u2014\u8fd9\u662f\u65b0\u624b\u6700\u7ecf\u5178\u7684\u5751\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u672f\u8bed\u5c0f\u8bcd\u5178\uff1a<strong>\u8fd4\u56de\u503c<\/strong>\uff08return value\uff09\u5c31\u662f\u300c\u51fd\u6570\u5e72\u5b8c\u6d3b\u540e\u9012\u7ed9\u4f60\u7684\u7ed3\u679c\u300d\u3002<code>input()<\/code> \u7684\u8fd4\u56de\u503c\u5c31\u662f\u7528\u6237\u8f93\u5165\u7684\u90a3\u6bb5\u6587\u672c\u3002<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u751f\u6d3b\u7c7b\u6bd4<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>input()<\/code> \u50cf<strong>\u81ea\u52a8\u552e\u8d27\u673a\u4e0a\u7684\u5bf9\u8bb2\u673a<\/strong>\uff1a\u673a\u5668\u5148\u5e7f\u64ad\u300c\u8bf7\u6295\u5e01\u300d\uff08\u63d0\u793a\u6587\u5b57\uff09\uff0c\u7136\u540e\u9759\u9759\u7b49\u4f60\u64cd\u4f5c\uff08\u7a0b\u5e8f\u6682\u505c\uff09\uff1b\u4f60\u6295\u5165\u786c\u5e01\uff08\u8f93\u5165\u5185\u5bb9\uff09\uff0c\u673a\u5668\u786e\u8ba4\u540e\u7ed9\u4f60\u5546\u54c1\uff08\u8fd4\u56de\u5b57\u7b26\u4e32\uff09\u3002\u5bf9\u8bb2\u673a\u6536\u8fdb\u53bb\u7684\u6c38\u8fdc\u662f\u4f60\u7684\u300c\u8bed\u97f3\u300d\uff08\u5b57\u7b26\u4e32\uff09\uff0c\u4e0d\u662f\u786c\u5e01\u672c\u8eab\uff08\u6570\u5b57\uff09\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u6ce8\u610f\u4e8b\u9879\u603b\u7ed3<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1 <strong>\u6700\u57fa\u672c\u7684\u8f93\u5165\u8f93\u51fa<\/strong>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>name = input(\"\u4f60\u53eb\u4ec0\u4e48\u540d\u5b57\uff1f\")\nprint(\"\u4f60\u597d\uff0c\", name)\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">2 <strong>input \u62ff\u5230\u7684\u6c38\u8fdc\u662f\u5b57\u7b26\u4e32<\/strong>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>num = input(\"\u8bf7\u8f93\u5165\u4e00\u4e2a\u6570\u5b57\uff1a\")\nprint(type(num))    # \u4e0d\u7ba1\u8f93\u5165\u4ec0\u4e48\uff0c\u8fd9\u91cc\u90fd\u663e\u793a &lt;class 'str'&gt;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">3 <strong>\u5148\u8f6c\u6362\u518d\u8ba1\u7b97<\/strong>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>num = input(\"\u8bf7\u8f93\u5165\u4e00\u4e2a\u6570\u5b57\uff1a\")\nnum = int(num)      # \u8f6c\u6210\u6574\u6570\nprint(num + 5)      # \u73b0\u5728\u80fd\u8ba1\u7b97\u4e86\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u6613\u9519\u70b9<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u9519\u8bef\u5199\u6cd5\uff1a<code>num = input(\"\u8f93\u5165\u6570\u5b57\uff1a\")<\/code> \u540e\u76f4\u63a5 <code>print(num * 2)<\/code> \u2192 \u95ee\u9898\uff1anum \u662f\u5b57\u7b26\u4e32\uff0c<code>\"10\" * 2<\/code> \u8f93\u51fa <code>1010<\/code>\uff08\u5b57\u7b26\u4e32\u91cd\u590d\u4e24\u904d\uff09\uff0c\u4e0d\u662f 20 \u2192 \u6b63\u786e\u5199\u6cd5\uff1a\u5148 <code>num = int(num)<\/code> \u518d\u4e58\u3002<\/li>\n\n\n\n<li>\u9519\u8bef\u5199\u6cd5\uff1a<code>int(input(\"...\"))<\/code> \u5374\u8f93\u5165\u4e86 <code>3.5<\/code> \u2192 \u95ee\u9898\uff1a<code>int(\"3.5\")<\/code> \u62a5 <code>ValueError<\/code> \u2192 \u6b63\u786e\u5199\u6cd5\uff1a\u7528 <code>float(input(...))<\/code> \u8f6c\u5c0f\u6570\u66f4\u901a\u7528\u3002<\/li>\n\n\n\n<li>\u9519\u8bef\u5199\u6cd5\uff1a\u8fd0\u884c\u542b <code>input()<\/code> \u7684\u7a0b\u5e8f\u540e\u4ec0\u4e48\u90fd\u4e0d\u8f93\u5165\uff0c\u5e72\u7b49\u7740 \u2192 \u95ee\u9898\uff1a\u7a0b\u5e8f\u4f1a\u4e00\u76f4\u6682\u505c\uff08\u963b\u585e\uff09 \u2192 \u6b63\u786e\u5199\u6cd5\uff1a\u5728\u63d0\u793a\u540e\u8f93\u5165\u5185\u5bb9\u518d\u6309\u56de\u8f66\u3002<\/li>\n\n\n\n<li>\u9519\u8bef\u5199\u6cd5\uff1a\u5728\u975e\u4ea4\u4e92\u73af\u5883\uff08\u5982\u67d0\u4e9b\u5728\u7ebf\u8fd0\u884c\u5668\uff09\u76f4\u63a5\u8dd1 input \u7a0b\u5e8f \u2192 \u95ee\u9898\uff1a\u6ca1\u6709\u7ec8\u7aef\u8f93\u5165\uff0c\u53ef\u80fd\u62a5 <code>EOFError<\/code> \u2192 \u6b63\u786e\u5199\u6cd5\uff1a\u5728\u672c\u5730\u7ec8\u7aef \/ VS Code \u91cc\u8fd0\u884c\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u8bb0\u5fc6\u53e3\u8bc0<\/strong>\uff1ainput \u95ee\u4e00\u53e5\uff0c\u56de\u8f66\u62ff\u6587\u672c\uff1b\u8981\u7b97\u5148\u8f6c\u6362\uff0c\u4e0d\u7136\u5c31\u7ffb\u8f66\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5 \u52a8\u624b\u5b9e\u8df5\uff1a\u8ba1\u7b97\u5668\u96cf\u5f62<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5199\u4e00\u4e2a\u7a0b\u5e8f\uff1a\u8f93\u5165\u4e24\u4e2a\u6570\u5b57\uff0c\u8f93\u51fa\u5b83\u4eec\u7684\u548c\u4e0e\u5e73\u5747\u503c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># calculator.py \u2014\u2014 \u8ba1\u7b97\u5668\u96cf\u5f62\nnum1 = input(\"\u8bf7\u8f93\u5165\u7b2c\u4e00\u4e2a\u6570\u5b57\uff1a\")\nnum2 = input(\"\u8bf7\u8f93\u5165\u7b2c\u4e8c\u4e2a\u6570\u5b57\uff1a\")\n\n# input \u8fd4\u56de\u7684\u662f\u5b57\u7b26\u4e32\uff0c\u5148\u8f6c\u6210\u5c0f\u6570\nnum1 = float(num1)\nnum2 = float(num2)\n\ntotal = num1 + num2\navg = total \/ 2\n\nprint(\"\u4e24\u6570\u4e4b\u548c\uff1a\", total)\nprint(\"\u4e24\u6570\u5e73\u5747\u503c\uff1a\", avg)\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd0\u884c\u793a\u4f8b\uff08\u4ea4\u4e92\uff1a\u4f9d\u6b21\u8f93\u5165 10\u300120 \u56de\u8f66\uff09\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u8bf7\u8f93\u5165\u7b2c\u4e00\u4e2a\u6570\u5b57\uff1a10\n\u8bf7\u8f93\u5165\u7b2c\u4e8c\u4e2a\u6570\u5b57\uff1a20\n\u4e24\u6570\u4e4b\u548c\uff1a 30.0\n\u4e24\u6570\u5e73\u5747\u503c\uff1a 15.0\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u60f3\u4e00\u60f3<\/strong>\uff1a\u4e3a\u4ec0\u4e48\u7528 <code>float()<\/code> \u800c\u4e0d\u662f <code>int()<\/code>\uff1f\u56e0\u4e3a\u7528\u6237\u53ef\u80fd\u8f93\u5165 3.5 \u8fd9\u6837\u7684\u5c0f\u6570\uff0c<code>float()<\/code> \u66f4\u901a\u7528\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u4eca\u65e5\u603b\u7ed3<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u56db\u79cd\u57fa\u672c\u7c7b\u578b\uff1aint \/ float \/ str \/ bool\uff0c\u80fd\u4e00\u773c\u5206\u8fa8\n\u5e26\u5f15\u53f7\u7684\u662f\u5b57\u7b26\u4e32\uff0c\u4e0d\u5e26\u5f15\u53f7\u7684\u662f\u6570\u5b57\uff1b<code>True<\/code> \/ <code>False<\/code> \u9996\u5b57\u6bcd\u5927\u5199\n<code>type()<\/code> \u80fd\u67e5\u770b\u6570\u636e\u7c7b\u578b\uff0c\u7c7b\u578b\u51b3\u5b9a\u884c\u4e3a\uff08\u540c\u662f <code>+<\/code>\uff0c\u62fc\u63a5\u4e0e\u76f8\u52a0\u4e0d\u540c\uff09\n<code>int()<\/code> \u622a\u65ad\u5c0f\u6570\u3001<code>float()<\/code> \u8f6c\u5c0f\u6570\u3001<code>str()<\/code> \u8f6c\u6587\u672c\uff1b\u5185\u5bb9\u4e0d\u50cf\u6570\u5b57\u8f6c\u6362\u5c31\u62a5 <code>ValueError<\/code>\n<code>input()<\/code> \u8fd4\u56de\u7684\u4e00\u5b9a\u662f\u5b57\u7b26\u4e32\uff0c\u8981\u8ba1\u7b97\u5f97\u5148\u8f6c\u6362\n\u5b8c\u6210\u300c\u8ba1\u7b97\u5668\u96cf\u5f62\u300d\uff0c\u80fd\u7528 float() \u5904\u7406\u5c0f\u6570\u8f93\u5165<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u62a5\u9519<\/th><th>\u539f\u56e0<\/th><th>\u4fee\u590d<\/th><\/tr><\/thead><tbody><tr><td><code>ValueError: invalid literal for int()<\/code><\/td><td>\u628a\u4e0d\u80fd\u8f6c\u6570\u5b57\u7684\u5b57\u7b26\u4e32\u8f6c\u6210 int\uff0c\u5982 <code>int(\"abc\")<\/code><\/td><td>\u68c0\u67e5\u8f93\u5165\u5185\u5bb9\uff0c\u6216\u5148\u7528 <code>isdigit()<\/code> \u5224\u65ad<\/td><\/tr><tr><td><code>TypeError: can only concatenate str<\/code><\/td><td>\u5b57\u7b26\u4e32\u548c\u6570\u5b57\u7528 + \u62fc\u63a5<\/td><td>\u5148\u628a\u6570\u5b57\u8f6c\u6210 str\uff0c\u6216\u7528 f-string<\/td><\/tr><tr><td><code>NameError: name 'x' is not defined<\/code><\/td><td>\u53d8\u91cf\u540d\u62fc\u9519\u6216\u6ca1\u5b9a\u4e49<\/td><td>\u68c0\u67e5\u62fc\u5199<\/td><\/tr><tr><td>\u6570\u5b57\u524d\u5bfc 0 \u62a5\u9519\uff08\u5982 <code>int(\"010\")<\/code>\uff09<\/td><td>\u65b0\u7248 Python \u4e0d\u5141\u8bb8\u5b57\u7b26\u4e32\u524d\u5bfc 0 \u8f6c int<\/td><td>\u7528 <code>int(\"10\")<\/code>\uff0c\u53bb\u6389\u524d\u5bfc 0<\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>1 \u6570\u636e\u7c7b\u578b\uff1aint \/ float \/ str \/ bool \u662f\u4ec0\u4e48\uff1f\u4e3a\u4ec0\u4e48\u5b66\uff1f \u6570\u636e\u7c7b\u578b\uff08data typ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[16,9],"tags":[],"class_list":["post-60","post","type-post","status-publish","format-standard","hentry","category-python","category-code-dev"],"_links":{"self":[{"href":"https:\/\/ltrainyard.icu\/index.php\/wp-json\/wp\/v2\/posts\/60","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ltrainyard.icu\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ltrainyard.icu\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ltrainyard.icu\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ltrainyard.icu\/index.php\/wp-json\/wp\/v2\/comments?post=60"}],"version-history":[{"count":2,"href":"https:\/\/ltrainyard.icu\/index.php\/wp-json\/wp\/v2\/posts\/60\/revisions"}],"predecessor-version":[{"id":131,"href":"https:\/\/ltrainyard.icu\/index.php\/wp-json\/wp\/v2\/posts\/60\/revisions\/131"}],"wp:attachment":[{"href":"https:\/\/ltrainyard.icu\/index.php\/wp-json\/wp\/v2\/media?parent=60"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ltrainyard.icu\/index.php\/wp-json\/wp\/v2\/categories?post=60"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ltrainyard.icu\/index.php\/wp-json\/wp\/v2\/tags?post=60"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}