{"id":1556,"date":"2022-01-08T12:15:42","date_gmt":"2022-01-08T04:15:42","guid":{"rendered":"http:\/\/139.9.1.231\/?p=1556"},"modified":"2022-01-08T18:06:13","modified_gmt":"2022-01-08T10:06:13","slug":"python-sequense","status":"publish","type":"post","link":"http:\/\/139.9.1.231\/index.php\/2022\/01\/08\/python-sequense\/","title":{"rendered":"python \u4e2d\u7684\u5e8f\u5217"},"content":{"rendered":"\n<p class=\"has-light-pink-background-color has-background\">python\u4e2d\u5e8f\u5217\u662f\u6700\u57fa\u672c\u7684\u6570\u636e\u7ed3\u6784\uff0c\u4ed6\u662f\u4e00\u5757\u7528\u4e8e\u5b58\u653e\u591a\u4e2a\u503c\u7684\u8fde\u7eed\u5185\u5b58\u7a7a\u95f4\u3002python\u4e2d\u5185\u7f6e\u4e865\u4e2a\u5e38\u7528\u7684\u5e8f\u5217\u7ed3\u6784\uff0c\u5206\u522b\u662f<strong>\u5217\u8868\u3001\u5143\u7ec4\u3001\u96c6\u5408\u3001\u5b57\u5178\u548c\u5b57\u7b26\u4e32<\/strong>\u3002<\/p>\n\n\n\n<p class=\"has-light-blue-background-color has-background\"><strong>1\u3001\u5e8f\u5217<\/strong>\uff1a\u5b58\u653e\u591a\u4e2a\u503c\u7684\u8fde\u7eed\u5185\u5b58\u7a7a\u95f4\u3002<\/p>\n\n\n\n<p>\u5e8f\u5217\u5305\u62ec\uff1a\u5217\u8868[ ]\uff0c\u5143\u7ec4 ( )\uff0c\u5b57\u5178{a:b}\uff0c\u96c6\u5408set={ a,b},\u5b57\u7b26\u4e32\uff1a&#8221;asdc&#8221;<\/p>\n\n\n\n<p class=\"has-medium-pink-color has-text-color has-medium-font-size\"><strong><em>\u5176\u4e2d\uff1a\u96c6\u5408\u548c\u5b57\u5178\u4e0d\u652f\u6301\u7d22\u5f15\u3001\u5207\u7247\u3001\u76f8\u52a0\u548c\u76f8\u4e58\u64cd\u4f5c\u3002<\/em><\/strong><\/p>\n\n\n\n<p>\u5e8f\u5217\u7d22\u5f15\uff1a\u6b63\u5e8f\u7d22\u5f15\uff0c\u4ece0\u5f00\u59cb\u5230n-1\uff0c\u5012\u5e8f\u7d22\u5f15\uff1a\u4ece-\uff08n-1\uff09\u5f00\u59cb\uff0c\u5230-1\u7ed3\u675f<\/p>\n\n\n\n<p>\u5207\u7247\uff1aname[start:end:step]<\/p>\n\n\n\n<p>\u76f8\u52a0\uff1aname1+name2<\/p>\n\n\n\n<p>\u4e58\u6cd5\uff1a name*2 \u8868\u793aname+name<\/p>\n\n\n\n<p>\u7a7a\u5e8f\u5217\uff1a [None]<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">\u68c0\u6d4b\u67d0\u4e2a\u5143\u7d20\u662f\u5426\u662f\u5e8f\u5217\u7684\u6210\u5458\uff1a x in sequence<\/p>\n\n\n\n<p>\u8ba1\u7b97\u5e8f\u5217\u7684\u957f\u5ea6\u3001\u6700\u5927\u5c0f\u503c\uff1a len( )\\\u3001max( )\u3001 min( )<\/p>\n\n\n\n<p>\u5176\u4ed6\u5185\u7f6e\u51fd\u6570\uff1a<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>list()<\/td><td>\u5c06\u5e8f\u5217\u8f6c\u6362\u4e3alist<\/td><\/tr><tr><td>str()<\/td><td>\u5c06\u5e8f\u5217\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32<\/td><\/tr><tr><td>sum()<\/td><td>\u8ba1\u7b97\u5143\u7d20\u548c<\/td><\/tr><tr><td>sorted()<\/td><td>\u6392\u5e8f<\/td><\/tr><tr><td>reversed()<\/td><td>\u5c06\u539f\u5e8f\u5217\u5143\u7d20\u53cd\u5411<\/td><\/tr><tr><td>enumerate()<\/td><td>\u5c06\u5e8f\u5217\u7ec4\u5408\u4e3a\u4e00\u4e2a\u7d22\u5f15\u5e8f\u5217<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"has-light-gray-background-color has-background\">python \u4e2d\u67e5\u770b\u6570\u636e\u7c7b\u578b\uff1a<\/p>\n\n\n\n<p>\u5185\u7f6e\u51fd\u6570isinstance(object, (type1,type2\u2026))<br>isinstance(&#8216;content&#8217;, str)<br>\u8fd4\u56deTrue or False<\/p>\n\n\n\n<p>\u4f7f\u7528\u5185\u7f6e\u51fd\u6570type(object)<br>print(type(1))<br>print(type(&#8216;content&#8217;))<\/p>\n\n\n\n<p class=\"has-light-blue-background-color has-background\"><strong>2\u3001\u5217\u8868<\/strong> list<\/p>\n\n\n\n<p>\u5217\u8868\u4e2d\u7684\u5143\u7d20\u53ef\u4ee5\u662f\u4efb\u610f\u5404\u79cd\u7c7b\u578b\u7684\u7ec4\u5408\u3002<\/p>\n\n\n\n<p>list(seqence ) \u5c06\u5e8f\u5217\u8f6c\u6362\u4e3a\u5217\u8868<\/p>\n\n\n\n<p>listname=[a,v,bd,d]<\/p>\n\n\n\n<p>\u8bbf\u95ee\u5e8f\u5217\u5143\u7d20 \uff1a<\/p>\n\n\n\n<p>for  i  in  list\uff1a<\/p>\n\n\n\n<p>for  index, item in enumerate(list):<\/p>\n\n\n\n<p>en<strong>umerate() \u51fd\u6570\u7528\u4e8e\u5c06\u4e00\u4e2a\u53ef\u904d\u5386\u7684\u6570\u636e\u5bf9\u8c61(\u5982\u5217\u8868\u3001\u5143\u7ec4\u6216\u5b57\u7b26\u4e32)\u7ec4\u5408\u4e3a\u4e00\u4e2a<em>\u7d22\u5f15\u5e8f\u5217\uff0c\u540c\u65f6\u5217\u51fa\u6570\u636e\u548c\u6570\u636e\u4e0b\u6807\uff0c\u4e00\u822c\u7528\u5728 for \u5faa\u73af\u5f53\u4e2d\u3002<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">enumerate(sequence, [start=0])\nsequence -- \u4e00\u4e2a\u5e8f\u5217\u3001\u8fed\u4ee3\u5668\u6216\u5176\u4ed6\u652f\u6301\u8fed\u4ee3\u5bf9\u8c61\u3002\nstart -- \u4e0b\u6807\u8d77\u59cb\u4f4d\u7f6e\u3002<\/pre>\n\n\n\n<p class=\"has-light-blue-background-color has-background\">\u6dfb\u52a0\u5143\u7d20\uff1a list.append(&#8220;x&#8221;)<\/p>\n\n\n\n<p>\u6dfb\u52a0\u591a\u4e2a\u5143\u7d20\uff1a list.extend(seqence)<\/p>\n\n\n\n<p class=\"has-light-blue-background-color has-background\">\u6839\u636e\u5143\u7d20\u503c\u5220\u9664\u5143\u7d20\uff1a list.remove(value)<\/p>\n\n\n\n<p class=\"has-light-blue-background-color has-background\">\u7edf\u8ba1\u6307\u5b9a\u5143\u7d20\u51fa\u73b0\u6b21\u6570\uff1alist.count(obj)<\/p>\n\n\n\n<p>\u83b7\u53d6\u6307\u5b9a\u5143\u7d20\u9996\u6b21\u51fa\u73b0\u7684\u4e0b\u6807\uff1alist.index(obj)<\/p>\n\n\n\n<p>\u7edf\u8ba1\u5143\u7d20\u548c\uff1asum(iterable[,start])<\/p>\n\n\n\n<p>start\u8868\u793a\u7edf\u8ba1\u7ed3\u679c\u9700\u8981\u5728 \u52a0\u4e0astart\u503c\u3002 start &#8212; \u6307\u5b9a\u76f8\u52a0\u7684\u53c2\u6570\uff0c\u5982\u679c\u6ca1\u6709\u8bbe\u7f6e\u8fd9\u4e2a\u503c\uff0c\u9ed8\u8ba4\u4e3a0\u3002<\/p>\n\n\n\n<p class=\"has-light-blue-background-color has-background\">\u6392\u5e8f:   list.sort(key=None,reverse=False)<\/p>\n\n\n\n<ul><li>key &#8212; \u4e3b\u8981\u662f\u7528\u6765\u8fdb\u884c\u6bd4\u8f83\u7684\u5143\u7d20\uff0c\u53ea\u6709\u4e00\u4e2a\u53c2\u6570\uff0c\u5177\u4f53\u7684\u51fd\u6570\u7684\u53c2\u6570\u5c31\u662f\u53d6\u81ea\u4e8e\u53ef\u8fed\u4ee3\u5bf9\u8c61\u4e2d\uff0c\u6307\u5b9a\u53ef\u8fed\u4ee3\u5bf9\u8c61\u4e2d\u7684\u4e00\u4e2a\u5143\u7d20\u6765\u8fdb\u884c\u6392\u5e8f\u3002<strong>\u5982\u8bbe\u7f6ekey=str.lower\uff0c\u8868\u793a\u5728\u6392\u5e8f\u65f6\u5019\u4e0d\u533a\u5206\u5b57\u6bcd\u5927\u5c0f\u5199\u3002<\/strong><\/li><li>reverse &#8212; \u6392\u5e8f\u89c4\u5219\uff0c<strong>reverse = True<\/strong>&nbsp;\u964d\u5e8f\uff0c&nbsp;<strong>reverse = False<\/strong>&nbsp;\u5347\u5e8f\uff08\u9ed8\u8ba4\uff09\u3002<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># \u83b7\u53d6\u5217\u8868\u7684\u7b2c\u4e8c\u4e2a\u5143\u7d20\ndef takeSecond(elem):\n    return elem&#91;1]\n \n# \u5217\u8868\nrandom = &#91;(2, 2), (3, 4), (4, 1), (1, 3)]\n \n# \u6307\u5b9a\u7b2c\u4e8c\u4e2a\u5143\u7d20\u6392\u5e8f\nrandom.sort(key=takeSecond)<\/code><\/pre>\n\n\n\n<p>\u4e2a\u4eba\u7406\u89e3\uff1a\u9996\u5148\u5c06list\u5143\u7d20\u9001\u5230key\u5b9a\u4e49\u7684\u51fd\u6570\u4e2d \uff0c\u7136\u540e\u518d\u628a\u8fd4\u56de\u503c\u8fdb\u884c\u6392\u5e8f\u3002 <\/p>\n\n\n\n<p>\u6392\u5e8f\uff1a\u4f7f\u7528\u5185\u7f6e\u7684sorted\u51fd\u6570\uff1a  sorted(iterable,key=None,reverse=False) <\/p>\n\n\n\n<p>\u5217\u8868\u63a8\u5bfc\u5f0f\uff1a<\/p>\n\n\n\n<p>list=[expression  for  x  in   range]<\/p>\n\n\n\n<p>range\u662f range ()\u51fd\u6570\u751f\u6210\u7684range\u5bf9\u8c61<\/p>\n\n\n\n<p>\u4ecex\u4e2d\u7b5b\u9009\u6ee1\u8db3codition\u7684x<\/p>\n\n\n\n<p>list = [expression for  x   in range  if  condition]<\/p>\n\n\n\n<p>\u4e8c\u7ef4\u5217\u8868\uff1a[[ ],[  ],[  ]]<\/p>\n\n\n\n<p>\u4f7f\u7528for\u5faa\u73af\u521b\u5efa\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>for i in range(4):   \n   arr.append(&#91;])\n   for j in range(5):\n      arr&#91;i].append&#91;j]\n\n<\/code><\/pre>\n\n\n\n<p>\u5217\u8868\u63a8\u5bfc\u5f0f\u521b\u5efa\uff1a<\/p>\n\n\n\n<p>arr = [[j for j in range(6)] for i in range(4)]<\/p>\n\n\n\n<p class=\"has-bright-blue-background-color has-background\"><strong>3\u3001\u5143\u7ec4<\/strong>:\u4e0d\u53ef\u53d8\u7684\u5217\u8868\uff0c\u5b9a\u4e49\u4ee5\u540e\u4e0d\u53ef\u4fee\u6539\uff0c\u53ea\u80fd\u91cd\u65b0\u5b9a\u4e49<\/p>\n\n\n\n<p>A=(1,2,3,4)<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\"><strong>tuple \u5143\u7ec4\uff1a\u4e0d\u53ef\u4fee\u6539\uff0c\u5728python\u4e2d\uff0c\u5143\u7ec4\u4f7f\u7528\u4e00\u5bf9\u5c0f\u62ec\u53f7\u5c06\u6240\u6709\u5143\u7d20\u62ec\u8d77\u6765\uff0c\u4f46\u5c0f\u62ec\u53f7\u5e76\u4e0d\u662f\u5fc5\u987b\u7684<\/strong>\uff0c<strong>\u53ea\u9700\u8981\u5c06\u4e00\u7ec4\u503c\u7528\u9017\u53f7\u5206\u9694\u5f00\uff0cpython\u5c31\u53ef\u4ee5\u89c6\u4e3a\u5143\u7ec4<\/strong> B=1\uff0c2\uff0c3\uff0c4\uff0c5 \u4e5f\u662f\u5143\u7ec4<\/p>\n\n\n\n<p>\u521b\u5efa\u5143\u7ec4 tuple(data)<\/p>\n\n\n\n<p class=\"has-light-gray-background-color has-background\">\u9898\u5916\u8bdd\uff1aprint(&#8220;ddd&#8221;,end=&#8221; &#8220;) \/\/\u8868\u793a\u4e0d\u6362\u884c\u8f93\u51fa<\/p>\n\n\n\n<p>\u56e0\u4e3a\u5143\u7ec4\u4e0d\u53ef\u4fee\u6539\uff0c\u56e0\u6b64\u9700\u8981\u5bf9\u5143\u7ec4\u4e2d\u67d0\u4e2a\u5143\u7d20\u4fee\u6539\u65f6\u9700\u8981\u91cd\u65b0\u5b9a\u4e49\u5143\u7ec4\uff1a<\/p>\n\n\n\n<p>A=(&#8220;W&#8221;,&#8221;Q&#8221;)<\/p>\n\n\n\n<p>A=(&#8220;w&#8221;,&#8221;q&#8221;)<\/p>\n\n\n\n<p class=\"has-light-blue-background-color has-background\">\u5143\u7ec4\u63a8\u5bfc\u5f0f\uff1a\u548clist\u7c7b\u4f3c\uff0c\u5c06[ ]\u53d8\u4e3a( ),\u5e76\u5728\u6700\u5916\u9762\u8fd8\u8981\u5d4c\u5957\u4e00\u5c42tuple( )\uff1a<\/p>\n\n\n\n<p>x= (i for i  in range) \/\/\u8fd9\u53e5\u751f\u6210\u7684\u7ed3\u679c\u4e0d\u662f\u4e00\u4e2a\u5143\u7ec4\uff0c\u800c\u662f\u4e00\u4e2a\u751f\u6210\u5668\u5bf9\u8c61\uff0c\u56e0\u6b64\u9700\u8981\u5343\u5e74\u5957\u4e00\u5c42tuple()<\/p>\n\n\n\n<p>tuple(x)\u5c31\u662f\u5143\u7ec4<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">4\u3001\u5b57\u5178 dict( ) == c++\u4e2d\u7684Map<\/p>\n\n\n\n<p>dictionary={&#8216;key&#8217;:&#8217;value&#8217;}<\/p>\n\n\n\n<p class=\"has-bright-blue-background-color has-background\">\u521b\u5efa\u5b57\u5178\uff1a<\/p>\n\n\n\n<p>dictionary = dict(zip(list1,list2))<\/p>\n\n\n\n<p><strong>zip()<\/strong>&nbsp;\u51fd\u6570\u7528\u4e8e\u5c06\u53ef\u8fed\u4ee3\u7684\u5bf9\u8c61\u4f5c\u4e3a\u53c2\u6570\uff0c\u5c06\u5bf9\u8c61\u4e2d\u5bf9\u5e94\u7684\u5143\u7d20\u6253\u5305\u6210\u4e00\u4e2a\u4e2a\u5143\u7ec4\uff0c\u7136\u540e\u8fd4\u56de\u7531\u8fd9\u4e9b\u5143\u7ec4\u7ec4\u6210\u7684\u5217\u8868\u3002<\/p>\n\n\n\n<p class=\"has-light-gray-background-color has-background\"> dictionary = dict(&#8216;key1&#8217;=&#8217;value1&#8242;,&#8217;key2&#8217;=&#8217;value2&#8217;,&#8230;.) <\/p>\n\n\n\n<p class=\"has-light-gray-background-color has-background\">\u521b\u5efa\u503c\u4e3a\u7a7a\u7684\u5b57\u5178\uff1a   dictionary   = dict.fromkeys(list)<\/p>\n\n\n\n<p>\u83b7\u53d6\u6307\u5b9a\u952e\u7684\u503c\uff1a<\/p>\n\n\n\n<p>dictionary.get(key[,default])<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">\u904d\u5386\u5b57\u5178\uff1a<\/p>\n\n\n\n<p>dictionary.item() \u8fd4\u56de\u201c\u952e-\u503c\u201d\u5217\u8868<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>for item  in  dictionary.item(): \u83b7\u5f97\u6bcf\u4e00\u4e2a\u952e\u503c\u5bf9\u5143\u7ec4\uff1a\uff08key,value\uff09\nfor key,value  in  dictionary.item(): \u83b7\u5f97\u6bcf\u4e00\u4e2a\u952e-\u503c<\/code><\/pre>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">\u5b57\u5178\u63a8\u5bfc\u5f0f\uff1a<\/p>\n\n\n\n<p>dictionary = {i:j for i,j in zip(list1,list2)}<\/p>\n\n\n\n<p class=\"has-bright-blue-background-color has-background\"><strong>5\u3001 \u96c6\u5408 set()<\/strong>\uff1a{ }\u96c6\u5408\u4e2d\u5143\u7d20\u4e0d\u91cd\u590d\uff0c\u7528\u4e8e\u81ea\u52a8\u53bb\u91cd<\/p>\n\n\n\n<p>\u521b\u5efaset \uff1ax = {1\uff0c2\uff0c3 } <\/p>\n\n\n\n<p>y=set(iteration)<\/p>\n\n\n\n<p>\u521b\u5efa\u7a7a\u96c6\u5408 z =set( )<\/p>\n\n\n\n<p class=\"has-light-gray-background-color has-background\">\u96c6\u5408\u7684\u589e\u5220\uff1a<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">setname.add(element) \/\/\u6dfb\u52a0\u5143\u7d20<\/p>\n\n\n\n<p class=\"has-light-blue-background-color has-background\">setname.remove(element) \/\/\u5220\u9664 \u5143\u7d20<\/p>\n\n\n\n<p class=\"has-light-blue-background-color has-background\"> setname.pop() \/\/\u5220\u9664\u5143\u7d20<\/p>\n\n\n\n<p class=\"has-light-blue-background-color has-background\"> setname.clear() \/\/\u6e05\u7a7aset  <\/p>\n\n\n\n<p class=\"has-light-gray-background-color has-background\">\u96c6\u5408\u7684\u4ea4\u5e76\u5dee\u8865\u8fd0\u7b97\uff1a &amp;  |  &#8211;   ^<\/p>\n\n\n\n<p class=\"has-light-gray-background-color has-background\">\u5b9e\u4f8b\uff1a c = set1&amp;set2 <\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">6\u3001\u5b57\u7b26\u4e32str()<\/p>\n\n\n\n<p>\u62fc\u63a5\u5b57\u7b26\u4e32\uff1a+<\/p>\n\n\n\n<p>\u8f6c\u6362\u5b57\u7b26\u4e32 str(num)<\/p>\n\n\n\n<p>\u8ba1\u7b97\u5b57\u7b26\u4e32\u957f\u5ea6 len(str)  <\/p>\n\n\n\n<p>\u8ba1\u7b97\u5b57\u7b26\u4e32\u6240\u5360\u5b57\u8282\u6570\uff1a len(str.encode())<\/p>\n\n\n\n<p>\u5b57\u7b26\u4e32\u7f16\u89e3\u7801 str.encode() str.decode()<\/p>\n\n\n\n<p>\u622a\u53d6\u5b57\u7b26\u4e32 string[start:end:step] (\u524d\u95ed\u540e\u5f00)<\/p>\n\n\n\n<p>\u5206\u5272\u5b57\u7b26str.split(seq,maxsplit)<\/p>\n\n\n\n<p>&nbsp;           seq &#8212; \u5206\u9694\u7b26\uff0c\u9ed8\u8ba4\u4e3a\u6240\u6709\u7684\u7a7a\u5b57\u7b26\uff0c\u5305\u62ec\u7a7a\u683c\u3001\u6362\u884c(\\n)\u3001\u5236\u8868\u7b26(\\t)\u7b49\u3002<\/p>\n\n\n\n<p>             maxsplit \u5206\u5272\u6b21\u6570\u3002\u9ed8\u8ba4\u4e3a -1, \u5373\u5206\u9694\u6240\u6709\u3002<\/p>\n\n\n\n<p>\u5408\u5e76\u5b57\u7b26\uff1astring.jion(iterable) \/\/ string \u5408\u5e76\u7b26\uff0c\u7528\u4e8e\u5408\u5e76\u65f6\u5019\u7684\u5206\u9694\u7b26<\/p>\n\n\n\n<p class=\"has-light-gray-background-color has-background\">\u68c0\u7d22\u5b57\u7b26\u4e32<\/p>\n\n\n\n<p>str.count(sub[,start,end]) \/\/\u7edf\u8ba1sub\u51fa\u73b0\u7684\u6b21\u6570<\/p>\n\n\n\n<p>str.find (sub[,start,end])\/\/ \u68c0\u7d22\u662f\u5426\u5b58\u5728sub\uff0c\u4e0d\u5b58\u5728\u8fd4\u56de-1\uff0c\u5426\u5219\u8fd4\u56de\u9996\u6b21\u51fa\u73b0\u7684\u4f4d\u7f6e <\/p>\n\n\n\n<p>str.index (sub[,start,end])\/\/ \u68c0\u7d22\u662f\u5426\u5b58\u5728sub \uff0c \u8fd4\u56de\u9996\u6b21\u51fa\u73b0\u7684\u4f4d\u7f6e \uff0c\u5982\u4e0d\u5b58\u5728\u4f1a\u62a5\u5f02\u5e38<\/p>\n\n\n\n<p> str.startwith(prefix[,start,end]) \/\/\u5224\u65ad\u662f\u5426\u4ee5prefix\u5f00\u5934\uff0c\u8fd4\u56detrue or flase<\/p>\n\n\n\n<p> str.endwith(prefix[,start,end]) \/\/\u5224\u65ad\u662f\u5426\u4ee5prefix\u7ed3\u5c3e\uff0c\u8fd4\u56detrue or flase <\/p>\n\n\n\n<p class=\"has-light-gray-background-color has-background\">\u5927\u5c0f\u5199\u8f6c\u6362\uff1a str.lower()   str.upper()<\/p>\n\n\n\n<p class=\"has-light-gray-background-color has-background\">\u53bb\u9664\u5b57\u7b26\u4e32\u4e2d\u7684\u7a7a\u683c\u548c\u7279\u6b8a\u5b57\u7b26<\/p>\n\n\n\n<p>str.strip([chars]) \/\/ chars \uff1a\u8981\u53bb\u9664\u7684\u5b57\u7b26\uff0c\u9ed8\u8ba4\u662f\u53bb\u9664\u7a7a\u683c\u3001\u5236\u8868\u7b26\\t,\u56de\u8f66\u7b26\\r \u6362\u884c\u7b26\\n<\/p>\n\n\n\n<p>str.lstrip([chars])<\/p>\n\n\n\n<p>str.rstrip([chars])<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>python\u4e2d\u5e8f\u5217\u662f\u6700\u57fa\u672c\u7684\u6570\u636e\u7ed3\u6784\uff0c\u4ed6\u662f\u4e00\u5757\u7528\u4e8e\u5b58\u653e\u591a\u4e2a\u503c\u7684\u8fde\u7eed\u5185\u5b58\u7a7a\u95f4\u3002python\u4e2d\u5185\u7f6e\u4e865\u4e2a\u5e38\u7528\u7684\u5e8f\u5217 &hellip; <a href=\"http:\/\/139.9.1.231\/index.php\/2022\/01\/08\/python-sequense\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">python \u4e2d\u7684\u5e8f\u5217<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8],"tags":[],"_links":{"self":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/1556"}],"collection":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/comments?post=1556"}],"version-history":[{"count":58,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/1556\/revisions"}],"predecessor-version":[{"id":1660,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/1556\/revisions\/1660"}],"wp:attachment":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/media?parent=1556"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/categories?post=1556"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/tags?post=1556"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}