{"id":205102,"date":"2025-05-29T16:14:42","date_gmt":"2025-05-29T08:14:42","guid":{"rendered":"https:\/\/server.hk\/cnblog\/205102\/"},"modified":"2025-05-29T16:14:42","modified_gmt":"2025-05-29T08:14:42","slug":"%e5%a6%82%e4%bd%95%e6%b6%88%e9%99%a4%e5%ad%97%e5%85%b8%e6%89%93%e5%8d%b0%e4%b8%ad%e7%9a%84%e7%a9%ba%e8%a1%8c%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/205102\/","title":{"rendered":"\u5982\u4f55\u6d88\u9664\u5b57\u5178\u6253\u5370\u4e2d\u7684\u7a7a\u884c\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u5982\u4f55\u6d88\u9664\u5b57\u5178\u6253\u5370\u4e2d\u7684\u7a7a\u884c\uff1f<\/h1>\n<p>\u73cd\u60dc\u65f6\u95f4\uff0c\u52e4\u594b\u5b66\u4e60\uff01\u4eca\u5929\u7ed9\u5927\u5bb6\u5e26\u6765\uff0c\u6b63\u6587\u5185\u5bb9\u4e3b\u8981\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\uff0c\u5982\u679c\u4f60\u6b63\u5728\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\uff0c\u6216\u8005\u662f\u5bf9<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u6709\u7591\u95ee\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u6211\uff01\u540e\u9762\u6211\u4f1a\u6301\u7eed\u66f4\u65b0\u76f8\u5173\u5185\u5bb9\u7684\uff0c\u5e0c\u671b\u90fd\u80fd\u5e2e\u5230\u6b63\u5728\u5b66\u4e60\u7684\u5927\u5bb6\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241123\/17323592836741b47394b94.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>\u89e3\u51b3\u5b57\u5178\u6253\u5370\u4e2d\u7684\u7a7a\u884c\u95ee\u9898<\/strong><\/p>\n<p>\u5728\u6253\u5370\u5b57\u5178\u65f6\uff0c\u60a8\u53ef\u80fd\u9047\u5230\u4e86\u4e2d\u95f4\u81ea\u52a8\u751f\u6210\u7a7a\u884c\u7684\u95ee\u9898\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539\u6253\u5370\u8bed\u53e5\u7684\u683c\u5f0f\u6765\u89e3\u51b3\u3002<\/p>\n<p>\u539f\u59cb\u4ee3\u7801\u65e0\u6cd5\u53bb\u6389\u7a7a\u884c\uff0c\u56e0\u4e3a strip(r&#8217;n&#8217;) \u51fd\u6570\u53ea\u80fd\u53bb\u9664\u5b57\u7b26\u4e32\u672b\u5c3e\u7684\u6362\u884c\u7b26\u3002<\/p>\n<p>\u4e3a\u4e86\u53bb\u9664\u5b57\u5178\u6253\u5370\u4e2d\u7684\u7a7a\u884c\uff0c\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre>if __name__ == \"__main__\":\n    dic = {1: '''a\n    ''',\n    2: '''b\n\n    ''',\n    3: '''c'''}\n    for item in dic.values():\n        print(item.strip())<\/pre>\n<p>\u6b64\u4ee3\u7801\u5c06\u9010\u4e2a\u904d\u5386\u5b57\u5178\u4e2d\u7684\u503c\uff0c\u5e76\u4f7f\u7528 strip() \u51fd\u6570\u53bb\u9664\u6bcf\u4e2a\u503c\u672b\u5c3e\u7684\u6362\u884c\u7b26\u548c\u7a7a\u767d\u7b26\u3002\u8fd9\u6837\u5c31\u53ef\u4ee5\u6253\u5370\u51fa\u5b57\u5178\u503c\uff0c\u800c\u4e0d\u4f1a\u51fa\u73b0\u7a7a\u884c\u3002<\/p>\n<p>\u597d\u4e86\uff0c\u672c\u6587\u5230\u6b64\u7ed3\u675f\uff0c\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u300a\u5982\u4f55\u6d88\u9664\u5b57\u5178\u6253\u5370\u4e2d\u7684\u7a7a\u884c\uff1f\u300b\uff0c\u5e0c\u671b\u672c\u6587\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff01\u5173\u6ce8\u516c\u4f17\u53f7\uff0c\u7ed9\u5927\u5bb6\u5206\u4eab\u66f4\u591a\u6587\u7ae0\u77e5\u8bc6\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u6d88\u9664\u5b57\u5178\u6253\u5370\u4e2d\u7684\u7a7a\u884c\uff1f \u73cd\u60dc&#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-205102","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/205102","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=205102"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/205102\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=205102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=205102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=205102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}