{"id":45612,"date":"2023-12-11T15:06:20","date_gmt":"2023-12-11T07:06:20","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=45612"},"modified":"2023-12-11T15:06:20","modified_gmt":"2023-12-11T07:06:20","slug":"%e5%86%99%e4%b8%80%e6%ae%b5%e7%a8%8b%e5%ba%8f%ef%bc%8c%e5%88%a0%e9%99%a4%e5%ad%97%e7%ac%a6%e4%b8%b2a%e4%b8%ad%e5%8c%85%e5%90%ab%e7%9a%84%e5%ad%97%e7%ac%a6%e4%b8%b2b%ef%bc%8c%e4%b8%be%e4%be%8b","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/12\/11\/%e5%86%99%e4%b8%80%e6%ae%b5%e7%a8%8b%e5%ba%8f%ef%bc%8c%e5%88%a0%e9%99%a4%e5%ad%97%e7%ac%a6%e4%b8%b2a%e4%b8%ad%e5%8c%85%e5%90%ab%e7%9a%84%e5%ad%97%e7%ac%a6%e4%b8%b2b%ef%bc%8c%e4%b8%be%e4%be%8b\/","title":{"rendered":"\u5199\u4e00\u6bb5\u7a0b\u5e8f\uff0c\u5220\u9664\u5b57\u7b26\u4e32a\u4e2d\u5305\u542b\u7684\u5b57\u7b26\u4e32b\uff0c\u4e3e\u4f8b \u8f93\u5165a = &#8220;asdw&#8221;,b = &#8220;sd&#8221; \u8fd4\u56de \u5b57\u7b26\u4e32 \u201caw\u201d\uff0c\u5e76\u4e14\u6d4b\u8bd5\u8fd9\u4e2a\u7a0b\u5e8f\u3002"},"content":{"rendered":"<p>&#8220;`&#8221;<\/p>\n<p>&lt;pre&gt;&lt;code class=&quot;&quot;language-python&quot;&quot; lang=&quot;&quot;python&quot;&quot;&gt;def delBString(a,b):<br \/>\n    if not isinstance(a,str):<br \/>\n        raise TypeError(&quot;&quot;a is not str&quot;&quot;)<br \/>\n    if not isinstance(b,str):<br \/>\n        raise TypeError(&quot;&quot;b is not str&quot;&quot;)<br \/>\n    if len(a) &lt; len(b):<br \/>\n        raise Exception(&#039;a length must large to b length&#039;)<br \/>\n    result = []<br \/>\n    flag = False<br \/>\n    i=0<br \/>\n    la = len(a)<br \/>\n    lb = len(b)<br \/>\n    while i &lt;la:<br \/>\n        j = 0<br \/>\n        while j &lt; lb:<br \/>\n            if i+j &lt; la and a[i+j] == b[j]:<br \/>\n                j += 1<br \/>\n            else :<br \/>\n                j += 1<br \/>\n                flag = False<br \/>\n                break<br \/>\n            flag = True<br \/>\n        if flag:<br \/>\n            i += lb<br \/>\n        else:<br \/>\n            result.append(a[i])<br \/>\n            i += 1<br \/>\n    return &quot;&quot;&quot;&quot;.join(result)<br \/>\n&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>\u00a0<\/p>\n<p>&lt;pre&gt;&lt;code class=&quot;&quot;language-python&quot;&quot; lang=&quot;&quot;python&quot;&quot;&gt;\u6d4b\u8bd5\u7528\u4f8b\uff1a<br \/>\nclass TestdelInnerStringFunctions():<br \/>\n    def setUp(self):<br \/>\n        pass<br \/>\n    def tearDown(self):<br \/>\n        pass<br \/>\n    def test_nomorl1(self):<br \/>\n        assert delBString(&#039;asdqwe&#039;,&#039;we&#039;) == &#039;asdq&#039;<br \/>\n    def test_nomorl2(self):<br \/>\n        assert delBString(&#039;asdqwe&#039;,&#039;0&#039;) == &#039;asdqwe&#039;<br \/>\n    def test_nomorl3(self):<br \/>\n        assert delBString(&#039;\u6d4b\u8bd5asdqwe&#039;,&#039;we&#039;) == &#039;\u6d4b\u8bd5asdq&#039;<br \/>\n    def test_nomorl4(self):<br \/>\n        assert delBString(&#039;\u6d4b\u8bd5asdqwe&#039;,&#039;\u6d4b\u8bd5&#039;) == &#039;asdqwe&#039;<br \/>\n    def test_nomorl5(self):<br \/>\n        assert delBString(&#039;asdqwe&#039;,&#039;&#039;) == &#039;asdqwe&#039;<br \/>\n    def test_nomorl6(self):<br \/>\n        with pytest.raises(TypeError):<br \/>\n            delBString(&#039;&#039;, 0)<br \/>\n    def test_nomorl7(self):<br \/>\n        with pytest.raises(TypeError):<br \/>\n            delBString(0, &#039;as&#039;)<br \/>\n    def test_nomorl8(self):<br \/>\n        with pytest.raises(TypeError):<br \/>\n            delBString(True)<br \/>\n    def test_nomorl9(self):<br \/>\n       with pytest.raises(Exception) as excinfo:<br \/>\n           delBString(&#039;acd&#039;,&#039;acde&#039;)<br \/>\n       assert &quot;&quot;a length must large to b length&quot;&quot; in str(excinfo.value)<br \/>\n       assert excinfo.type == Exception<br \/>\n&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>&lt;pre&gt;&lt;code&gt;            &quot;&#8220;`<br \/>\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;`&#8221; &lt;pre&gt;&lt;code class=&quot;&quot;l [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-45612","post","type-post","status-publish","format-standard","hentry","category-c"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/45612","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/comments?post=45612"}],"version-history":[{"count":1,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/45612\/revisions"}],"predecessor-version":[{"id":45613,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/45612\/revisions\/45613"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=45612"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=45612"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=45612"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}