{"id":94759,"date":"2020-05-14T10:14:23","date_gmt":"2020-05-14T02:14:23","guid":{"rendered":"http:\/\/4563.org\/?p=94759"},"modified":"2020-05-14T10:14:23","modified_gmt":"2020-05-14T02:14:23","slug":"%e5%a6%82%e4%bd%95%e7%bc%96%e7%a8%8b%ef%bc%88%e6%af%94%e5%a6%82%e7%94%a8-python-%ef%bc%89%e5%ae%9e%e7%8e%b0%e7%bb%99%e6%9c%ac%e5%9c%b0-markdown-%e6%96%87%e4%bb%b6%e6%a0%87%e9%a2%98%e6%b7%bb%e5%8a%a0","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=94759","title":{"rendered":"\u5982\u4f55\u7f16\u7a0b\uff08\u6bd4\u5982\u7528 Python \uff09\u5b9e\u73b0\u7ed9\u672c\u5730 Markdown \u6587\u4ef6\u6807\u9898\u6dfb\u52a0\u5206\u7ea7\u5e8f\u53f7\uff1f\u65ad\u65ad\u7eed\u7eed\u7422\u78e8\u4e24\u5929\u90fd\u6ca1\u60f3\u6e05\u695a\u3002\u3002"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u5982\u4f55\u7f16\u7a0b\uff08\u6bd4\u5982\u7528 Python \uff09\u5b9e\u73b0\u7ed9\u672c\u5730 Markdown \u6587\u4ef6\u6807\u9898\u6dfb\u52a0\u5206\u7ea7\u5e8f\u53f7\uff1f\u65ad\u65ad\u7eed\u7eed\u7422\u78e8\u4e24\u5929\u90fd\u6ca1\u60f3\u6e05\u695a\u3002\u3002               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Higurashi <\/span>  <span><i><\/i> 17<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u73b0\u5728\u6709\u4e00\u4e2a\u6709\u5f88\u591a\u7ea7\u76ee\u5f55\u7684 Markdown \u6587\u4ef6\uff0c\u5982\uff1a<\/p>\n<pre><code># \u6807\u9898 1  ### \u6807\u9898 2  ### \u6807\u9898 3  #### \u6807\u9898 4  #### \u6807\u9898 5  ## \u6807\u9898 6  ##### \u6807\u9898 7  ###### \u6807\u9898 8 <\/code><\/pre>\n<p>\u8be5\u5982\u4f55\u7f16\u5199\u7a0b\u5e8f\u5b9e\u73b0\u5728\u6bcf\u4e2a\u6807\u9898\u524d\u6dfb\u52a0\u7f16\u53f7\uff1f\uff08\u5982\u4e0b\uff09\uff1a<\/p>\n<pre><code># 1. \u6807\u9898 1  ### 1.1 \u6807\u9898 2  ### 1.2 \u6807\u9898 3  #### 1.2.1 \u6807\u9898 4  #### 1.2.2 \u6807\u9898 5  # 2. \u6807\u9898 6  ##### 2.1 \u6807\u9898 7  ###### 2.2 \u6807\u9898 8 <\/code><\/pre>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>8<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"1228205\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zhybzc <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u670d\u4e86\uff0c\u6211\u600e\u4e48\u77e5\u9053\u4f60\u4ec0\u4e48\u65f6\u5019\u9700\u8981 1.2.1 \u30011.2.2 \u554a\uff1f\u4e4b\u524d\u4ee5\u4e3a\u662f 1.3 \u30011.4 \u3002\u6240\u4ee5\u5199\u7684\u662f 1.3 \u30011.4\uff0c\u4f60\u53ef\u4ee5\u53c2\u8003\u4e0b\uff0c\u9664\u4e86 1.2.1 \u53d8\u6210\u4e86 1.3\uff0c1.2.2 \u53d8\u6210\u4e86 1.4\uff0c\u5176\u4ed6\u90fd\u662f\u4e00\u6837\u7684\uff1a<\/p>\n<p>with open(&#8220;test.md&#8221;, &#8220;r+&#8221; , encoding=&#8217;utf-8&#8242;) as f:<br \/> text=f.read()<br \/> f.seek(0)<br \/> a=0<br \/> b=0<br \/> c=0<br \/> for i in text.splitlines():<br \/> print(i)<br \/> if 0&lt;i.count(&#8216;#&#8217;)&lt;3:<br \/> a=a+1<br \/> space=i.find(&#8216; &#8216;)<br \/> i=list(i)<br \/> i.insert(space+1, str(a)+&#8217;. &#8216;)<br \/> i=&#8221;.join(i)<br \/> f.write(i+&#8217;n&#8217;)<br \/> f.flush()<br \/> b=0<br \/> c=a<\/p>\n<p> elif i.count(&#8216;#&#8217;)&gt;=3:<br \/> b=c+b+0.1<br \/> b=round(b,1)<br \/> space=i.find(&#8216; &#8216;)<br \/> i=list(i)<br \/> i.insert(space+1, str(b)+&#8217; &#8216;)<br \/> i=&#8221;.join(i)<br \/> f.write(i+&#8217;n&#8217;)<br \/> f.flush()<br \/> c=0<\/p>\n<p> else:<br \/> f.write(i+&#8217;n&#8217;)<br \/> f.flush()                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1228206\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zhybzc <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             https:\/\/img.alicdn.com\/imgextra\/i4\/78065018\/O1CN01lMz7DH1mwI3Sgntns_!!78065018.png                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1228207\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Higurashi <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @zhybzc \u4e4b\u524d\u6211\u8fd8\u6ca1\u8bf4\u5f97\u5f88\u6e05\u695a\uff0c\u4e8b\u5b9e\u4e0a\uff0c\u4e0a\u9762\u5176\u5b9e\u53ea\u662f\u4e2a\u4f8b\u5b50\u3002\u8fd9\u4e2a\u7a0b\u5e8f\u867d\u7136\u53ef\u4ee5\u5b9e\u73b0\u7ed9\u8fd9\u4e2a\u4f8b\u5b50\u7f16\u53f7\uff0c\u4f46\u5bf9\u4e0b\u9762\u8fd9\u7c7b\u60c5\u51b5\uff1a<br \/>&#8220;`<br \/>### \u6807\u9898 1<\/p>\n<p>#### \u6807\u9898 2<\/p>\n<p>#### \u6807\u9898 3<\/p>\n<p>#### \u6807\u9898 4<\/p>\n<p>##### \u6807\u9898 5<\/p>\n<p>##### \u6807\u9898 6<\/p>\n<p>## \u6807\u9898 7<\/p>\n<p>##### \u6807\u9898 8<\/p>\n<p>##### \u6807\u9898 9<br \/>&#8220;`<br \/>\u53ef\u80fd\u5c31\u65e0\u80fd\u4e3a\u529b\u4e86\uff0c\u4f46\u8fd9\u6837\u4e00\u79cd\u60c5\u51b5\u6309\u7167\u6211\u4eec\u5e73\u65f6\u5199 Markdown \u7684\u4e60\u60ef\u5176\u5b9e\u662f\u53ef\u4ee5\u5982\u4e0b\u7f16\u53f7\u7684\uff1a<br \/>&#8220;`<br \/>### 1. \u6807\u9898 1<\/p>\n<p>#### 1.1 \u6807\u9898 2<\/p>\n<p>#### 1.2 \u6807\u9898 3<\/p>\n<p>#### 1.3 \u6807\u9898 4<\/p>\n<p>##### 1.3.1 \u6807\u9898 5<\/p>\n<p>##### 1.3.2 \u6807\u9898 6<\/p>\n<p>## 2. \u6807\u9898 7<\/p>\n<p>##### 2.1 \u6807\u9898 8<\/p>\n<p>#####2.2 \u6807\u9898 9<br \/>&#8220;`<br \/>\u4e5f\u5c31\u662f\u8bf4\uff0c\u8fd9\u4e2a\u7a0b\u5e8f\u7684\u76ee\u7684\u5c31\u662f\u5e2e\u52a9\u6211\u4eec\u4e3a\u5e73\u65f6\u80fd\u591f\u6dfb\u52a0\u7f16\u53f7\u7684\u5404\u79cd\u60c5\u51b5\u6dfb\u52a0\u7f16\u53f7\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1228208\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zhybzc <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Higurashi #\u53f7\u7a81\u7136\u53d8\u5c11\u5c31\u4ece 1 \u53d8\u6210 2 \u662f\u5427\uff1f\u6bd4\u5982\u4f60\u521a\u4e3e\u7684\u4f8b\u5b50\u4e2d\u4ece 5 \u4e2a#\u53f7\u53d8\u6210 2 \u4e2a#\u53f7\uff0c\u5e8f\u53f7\u5c31\u4ece 1 \u53d8\u6210 2 \u4e86\u3002\u53ef\u662f\u5982\u679c 1.3.2 \u540e\u9762\u8fd8\u6709 1.4 \u5462\uff1f 1.3.2 \u540e\u9762\u5982\u679c\u662f 4 \u4e2a#\u53f7\u5c31\u662f 1.4 \u5417\uff1f<br \/>\u5927\u6807\u9898\u4e2d 1 \u662f\u4e09\u4e2a#\u53f7\uff0c\u600e\u4e48 2 \u53c8\u53ea\u6709\u4e24\u4e2a#\u53f7\uff1f<\/p>\n<p>\u6211\u4e0d\u592a\u61c2 Markdown \u7684\u4e60\u60ef\uff0c\u4e5f\u4e0d\u4e00\u5b9a\u6bcf\u4e2a\u4eba\u90fd\u4e00\u6837\u5427\uff1f\u5e8f\u53f7\u4e5f\u672c\u8eab\u662f\u624b\u52a8\u6807\u7684\uff0cMarkdown \u4e0d\u4f1a\u9ed8\u8ba4\u751f\u6210\u3002\u603b\u4e4b\u6211\u4f9d\u7136\u65e0\u6cd5\u5b8c\u5168\u641e\u6e05\u695a\u4f60\u7684\u6240\u6709\u9700\u6c42\u3002<\/p>\n<p>\u53ea\u8981\u4f60\u80fd\u591f\u628a\u9700\u6c42\u5b8c\u5168\u8bf4\u660e\u767d\uff0c\u8fd8\u662f\u5f88\u597d\u5b9e\u73b0\u7684\u3002\u53ea\u662f\u7a0d\u5fae\u6709\u70b9\u9ebb\u70e6\uff0c\u6211\u5c31\u61d2\u5f97\u518d\u5199\u4e86\u3002\u6211\u4e4b\u524d\u5199\u7684\u4f60\u7a0d\u5fae\u53c2\u8003\u4e0b\u5427\uff0c\u5927\u81f4\u5957\u8def\u5c31\u662f\u90a3\u6837\u7684\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1228209\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Higurashi <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @zhybzc \u55ef\u55ef\uff0c\u597d\u3002Thanks.                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1228210\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Higurashi <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @zhybzc \u4e4b\u524d\u7684\u95ee\u9898\u5df2\u7ecf\u5b8c\u5584\u4e86\u3002\u3002\u611f\u5174\u8da3\u7684\u8bdd\u53ef\u4ee5\u770b\u770b\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1228211\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zhybzc <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Higurashi \u6211\u7528\u4e0d\u5230\uff0c\u56e0\u4e3a\u6211\u81ea\u5df1\u672c\u8eab\u6ca1\u8fd9\u9700\u6c42\u3002\u6211\u4e5f\u4e0d\u6e05\u695a\u4f60\u7684\u9700\u6c42\u662f\u4ec0\u4e48\uff0c\u6309\u4f60\u8bf4\u7684\u4f3c\u4e4e\u53ea\u6709\u81ea\u5df1\u5199\u7b14\u8bb0\u7684\u65f6\u5019#\u53f7\u6807\u5f97\u5f88\u89c4\u5219\u624d\u80fd\u6709\u7528\u3002\u65e2\u7136\u8fd9\u6837\uff0c\u90a3\u8fd8\u4e0d\u5982\u624b\u52a8\u6807\u3002<\/p>\n<p>\u53e6\u5916\u7528\u592a\u591a\u6807\u9898\u4f5c\u4e3a\u5c42\u7ea7\u7684\u7b14\u8bb0\u5e76\u4e0d\u597d\u770b\uff0c\u5c42\u7ea7\u592a\u591a\u7528\u9879\u76ee\u7b26\u53f7\u6216\u8005\u7f29\u8fdb\u66f4\u597d\u3002\u4f60\u7684\u4ee3\u7801\u7ecf\u8fc7\u6211\u4e4b\u524d\u7684\u6d4b\u8bd5\u53d1\u73b0\u597d\u50cf\u53ea\u6709#\u53f7\u5f88\u89c4\u5219\u7684\u60c5\u51b5\u4e0b\u624d\u6709\u7528\uff0c\u5982\u679c\u968f\u673a\u5728\u67d0\u4e9b\u884c\u52a0\u5165\u4e00\u4e9b#\u53f7\uff0c\u6700\u7ec8\u6807\u51fa\u6765\u7684\u5e8f\u53f7\u662f\u975e\u5e38\u4e71\u7684\u3002<\/p>\n<p>\u6211\u4e4b\u524d\u6ca1\u4e8b\u4e5f\u6709\u8bd5\u7740\u91cd\u65b0\u5199\u4e86\u4e00\u4e0b\uff0c\u6211\u5199\u7684\u4ee3\u7801\u5373\u4fbf\u5728#\u53f7\u968f\u673a\u6807\u5f97\u5f88\u4e71\u7684\u60c5\u51b5\u4e0b\u6dfb\u52a0\u7684\u5e8f\u53f7\u4e5f\u8fd8\u7b97\u89c4\u5219\u3002\u53ea\u662f\u4e0d\u77e5\u9053\u7a76\u7adf\u8be5\u7528\u4ec0\u4e48\u7b97\u6cd5\uff0c\u4e0d\u77e5\u9053\u662f\u76f8\u540c\u7684#\u53f7\u6570\u91cf\u7528\u76f8\u540c\u7684\u5c42\u7ea7\u8fd8\u662f\u7528\u76f8\u5bf9\u7684\u65b9\u5f0f\u589e\u52a0\u6216\u51cf\u5c11\u5c42\u7ea7\uff0c\u76f8\u5bf9\u7684\u65b9\u5f0f\u5c31\u662f\u8bf4\u53d1\u73b0#\u53f7\u6bd4\u4e0a\u4e00\u884c\u591a\u5c31\u589e\u52a0\u4e00\u4e2a\u5c42\u7ea7\uff0c\u6bd4\u4e0a\u4e00\u884c\u5c11\u5c31\u51cf\u5c11\u4e00\u4e2a\u5c42\u7ea7\u3002<\/p>\n<p>\u603b\u4e4b\u4e0d\u7ba1\u7528\u4ec0\u4e48\u65b9\u5f0f\u90fd\u65e0\u6cd5\u4fdd\u8bc1\u5f88\u89c4\u5219\uff0c\u6700\u7ec8\u90fd\u8fd8\u662f\u53ef\u80fd\u6807\u5f97\u5f88\u4e71\u3002\u6211\u611f\u89c9\u8fd9\u4e2a\u7a0b\u5e8f\u5b9e\u5728\u6ca1\u4ec0\u4e48\u7528\u3002\u9664\u975e\u4f60\u80fd\u660e\u786e\u81ea\u5df1\u7684\u9700\u6c42\uff0c\u786e\u4fdd\u81ea\u5df1\u5728\u7b14\u8bb0\u4e2d\u7684\u5e8f\u53f7\u4e00\u5b9a\u662f\u89c4\u5219\u7684\uff0c\u4e00\u5b9a\u662f\u4f60\u9884\u5148\u8003\u8651\u5230\u7684\u60c5\u51b5\uff0c\u4e0d\u4f1a\u51fa\u73b0\u5176\u4ed6\u7279\u6b8a\u60c5\u51b5\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u6211\u540e\u6765\u5199\u7684\u4ee3\u7801\uff1a<br \/>http:\/\/note.youdao.com\/noteshare?id=3cd18b9191d748c0db3dabb6893da3d1                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1228212\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zhybzc <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Higurashi \u521a\u8fd8\u662f\u8bd5\u4e86\u4e00\u4e0b\uff0c\u53d1\u73b0\u6709\u62a5\u9519\uff0c\u5177\u4f53\u9519\u8bef\u63d0\u793a\u53ef\u770b\u8fd9\u7bc7\u7b14\u8bb0\uff1a<\/p>\n<p>http:\/\/note.youdao.com\/noteshare?id=b7397b8746fe671545ea1fe327c89ba5                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u7f16\u7a0b\uff08\u6bd4\u5982\u7528 Python \uff09&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/94759"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=94759"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/94759\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=94759"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=94759"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=94759"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}