{"id":204589,"date":"2025-05-29T10:33:49","date_gmt":"2025-05-29T02:33:49","guid":{"rendered":"https:\/\/server.hk\/cnblog\/204589\/"},"modified":"2025-05-29T10:33:49","modified_gmt":"2025-05-29T02:33:49","slug":"python3-%e6%89%a7%e8%a1%8c%e8%84%9a%e6%9c%ac%e6%97%b6%e6%8a%a5%e9%94%99-typeerror-not-all-arguments-converted-during-string-formatting-%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/204589\/","title":{"rendered":"Python3 \u6267\u884c\u811a\u672c\u65f6\u62a5\u9519 &#8220;TypeError: not all arguments converted during string formatting&#8221; \u5982\u4f55\u89e3\u51b3\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>Python3 \u6267\u884c\u811a\u672c\u65f6\u62a5\u9519 &#8220;TypeError: not all arguments converted during string formatting&#8221; \u5982\u4f55\u89e3\u51b3\uff1f<\/h1>\n<p>\u672c\u7bc7\u6587\u7ae0\u7ed9\u5927\u5bb6\u5206\u4eab\u300aPython3 \u6267\u884c\u811a\u672c\u65f6\u62a5\u9519 &#8220;TypeError: not all arguments converted during string formatting&#8221; \u5982\u4f55\u89e3\u51b3\uff1f\u300b\uff0c\u8986\u76d6\u4e86\u6587\u7ae0\u7684\u5e38\u89c1\u57fa\u7840\u77e5\u8bc6\uff0c\u5176\u5b9e\u4e00\u4e2a\u8bed\u8a00\u7684\u5168\u90e8\u77e5\u8bc6\u70b9\u4e00\u7bc7\u6587\u7ae0\u662f\u4e0d\u53ef\u80fd\u8bf4\u5b8c\u7684\uff0c\u4f46\u5e0c\u671b\u901a\u8fc7\u8fd9\u4e9b\u95ee\u9898\uff0c\u8ba9\u8bfb\u8005\u5bf9\u81ea\u5df1\u7684\u638c\u63e1\u7a0b\u5ea6\u6709\u4e00\u5b9a\u7684\u8ba4\u8bc6(B \u6570)\uff0c\u4ece\u800c\u5f25\u8865\u81ea\u5df1\u7684\u4e0d\u8db3\uff0c\u66f4\u597d\u7684\u638c\u63e1\u5b83\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241111\/173129962467318928480af.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>python3\u6267\u884c\u811a\u672c\u65f6\u62a5\u9519&#8221;typeerror: not all arguments converted during string formatting&#8221;\u89e3\u51b3\u65b9\u6cd5<\/strong><\/p>\n<p>\u5728\u6267\u884cpython3\u811a\u672c\u65f6\uff0c\u9047\u5230\u5982\u4e0b\u62a5\u9519\uff1a<\/p>\n<pre>typeerror: not all arguments converted during string formatting<\/pre>\n<p>\u9996\u5148\uff0c\u9700\u8981\u68c0\u67e5\u811a\u672c\u4ee3\u7801\uff0c\u5206\u6790\u62a5\u9519\u5185\u5bb9\uff0c\u5982\u4e0b\u4ee3\u7801\u6bb5\uff1a<\/p>\n<pre>out_tgt.write('%s\\n' % rows)<\/pre>\n<p>\u5176\u4e2d\uff0cout_tgt\u662f\u4e00\u4e2a\u6587\u4ef6\u5bf9\u8c61\uff0crows\u662f\u4e00\u4e2a\u5143\u7ec4\uff0c\u5f53\u5bf9\u5176\u8fdb\u884c\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u65f6\u5b58\u5728\u95ee\u9898\uff0c\u63d0\u793a\u8f6c\u6362\u4e0d\u5b8c\u5168\uff0c\u5bfc\u81f4\u62a5\u9519\u3002<\/p>\n<p>\u89e3\u51b3\u65b9\u6cd5\uff1a<\/p>\n<p>\u5c06out_tgt.write(&#8216;%sn&#8217; % rows)\u8bed\u53e5\u4fee\u6539\u4e3aout_tgt.write(&#8216;%sn&#8217; % (rows,))\uff0c\u5728\u5143\u7ec4\u5468\u56f4\u6dfb\u52a0\u4e00\u4e2a\u5c0f\u62ec\u53f7\uff0c\u5373\u53ef\u89e3\u51b3\u95ee\u9898\u3002<\/p>\n<p><strong>\u4fee\u6539\u540e\u4ee3\u7801\u6bb5\uff1a<\/strong><\/p>\n<pre>out_tgt.write('%s\\n' % (rows,))<\/pre>\n<p>\u6587\u4e2d\u5173\u4e8e\u7684\u77e5\u8bc6\u4ecb\u7ecd\uff0c\u5e0c\u671b\u5bf9\u4f60\u7684\u5b66\u4e60\u6709\u6240\u5e2e\u52a9\uff01\u82e5\u662f\u53d7\u76ca\u532a\u6d45\uff0c\u90a3\u5c31\u52a8\u52a8\u9f20\u6807\u6536\u85cf\u8fd9\u7bc7\u300aPython3 \u6267\u884c\u811a\u672c\u65f6\u62a5\u9519 &#8220;TypeError: not all arguments converted during string formatting&#8221; \u5982\u4f55\u89e3\u51b3\uff1f\u300b\u6587\u7ae0\u5427\uff0c\u4e5f\u53ef\u5173\u6ce8\u516c\u4f17\u53f7\u4e86\u89e3\u76f8\u5173\u6280\u672f\u6587\u7ae0\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python3 \u6267\u884c\u811a\u672c\u65f6\u62a5\u9519 &#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-204589","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204589","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=204589"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204589\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=204589"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=204589"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=204589"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}