{"id":193,"date":"2023-02-22T22:11:08","date_gmt":"2023-02-22T14:11:08","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=193"},"modified":"2023-02-22T22:11:34","modified_gmt":"2023-02-22T14:11:34","slug":"python-format-thousandth-digits","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/22\/python-format-thousandth-digits\/","title":{"rendered":"Python\u683c\u5f0f\u5316\u5343\u5206\u4f4d\u6570\u5b57"},"content":{"rendered":"<h3>Python 2.7\u53ca\u4ee5\u4e0a\u7248\u672c\u76f4\u63a5\u4f7f\u7528format\u8bbe\u7f6e\u5343\u5206\u4f4d\u5206\u9694\u7b26<\/h3>\n<pre><code class=\"language-python\">Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:25:58) [MSC v.1500 64 bit (AMD64)] on win32\nType &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.\n>&gt;&gt; format(1234567890, &#039;,&#039;)\n&#039;1,234,567,890&#039;\n>&gt;&gt;<\/code><\/pre>\n<p><!-- more --><\/p>\n<h3>\u6b63\u5219\u5b9e\u73b0<\/h3>\n<pre><code class=\"language-python\">import re\ndef number_format(s):\n    s = str(s)\n    while True:\n        (s, count) = re.subn(r&quot;(\\d)(\\d{3})((:?,\\d\\d\\d)*)$&quot;, r&quot;\\1,\\2\\3&quot;, s)\n        if count == 0 : break\n    return s\nprint number_format(1234567890)<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Python 2.7\u53ca\u4ee5\u4e0a\u7248\u672c\u76f4\u63a5\u4f7f\u7528format\u8bbe\u7f6e\u5343\u5206\u4f4d\u5206\u9694\u7b26 Python 2.7.14 (v2.7.1 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[79],"tags":[],"class_list":["post-193","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/193","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=193"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/193\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=193"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=193"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=193"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}