{"id":2531,"date":"2022-08-14T22:24:53","date_gmt":"2022-08-14T14:24:53","guid":{"rendered":"http:\/\/cnliutz.uicp.io\/?p=2531"},"modified":"2022-08-14T22:24:53","modified_gmt":"2022-08-14T14:24:53","slug":"%e5%ba%8f%e5%88%97%e8%bf%90%e7%ae%97%e3%80%81%e6%93%8d%e4%bd%9c%e3%80%81%e5%87%bd%e6%95%b0-%e6%96%b9%e6%b3%95%e7%ae%80%e4%bb%8b","status":"publish","type":"post","link":"http:\/\/g1n29wqq.ipyingshe.net:5347\/?p=2531","title":{"rendered":"\u5e8f\u5217\u8fd0\u7b97\u3001\u64cd\u4f5c\u3001\u51fd\u6570\/\u65b9\u6cd5\u7b80\u4ecb"},"content":{"rendered":"\n<p><strong>1.\u5e8f\u5217<\/strong><\/p>\n\n\n\n<p><strong>(1) \u5e8f\u5217\u7684\u6807\u51c6\u7c7b\u578b\u8fd0\u7b97<\/strong><\/p>\n\n\n\n<p>&lt;\u3001&gt;\u3001&lt;=\u3001&gt;=\u3001==\u3001!= \u503c\u6bd4\u8f83<\/p>\n\n\n\n<p>is\u3001is not \u5bf9\u8c61\u8eab\u4efd\u6bd4\u8f83<\/p>\n\n\n\n<p>and\u3001or\u3001not \u903b\u8f91\u8fd0\u7b97<\/p>\n\n\n\n<p><strong>(2) \u901a\u7528\u5e8f\u5217\u7c7b\u578b\u64cd\u4f5c<\/strong><\/p>\n\n\n\n<p>seq[start: end] \u5207\u7247\u64cd\u4f5c<\/p>\n\n\n\n<p>* \u91cd\u590d\u7ec4\u5408\u5e8f\u5217\u6570\u636e<\/p>\n\n\n\n<p>+ \u8fde\u63a5 2 \u4e2a\u5e8f\u5217<\/p>\n\n\n\n<p>in\u3001not in \u5224\u65ad\u5143\u7d20\u662f\u5426\u5b58\u5728\u5e8f\u5217\u4e2d<\/p>\n\n\n\n<p><strong>(3) \u5e8f\u5217\u5e38\u7528\u51fd\u6570<\/strong><\/p>\n\n\n\n<p>\u51fd\u6570 \u63cf \u8ff0<\/p>\n\n\n\n<p>list(iter) \u5c06\u53ef\u8fed\u4ee3\u5bf9\u8c61iter\u8f6c\u6362\u6210\u5217\u8868<\/p>\n\n\n\n<p>tuple(iter) \u5c06\u53ef\u8fed\u4ee3\u5bf9\u8c61iter\u8f6c\u6362\u6210\u5143\u7ec4<\/p>\n\n\n\n<p>str(obj) \u5c06\u5bf9\u8c61obj\u8f6c\u6362\u6210\u5b57\u7b26\u4e32\u8868\u793a<\/p>\n\n\n\n<p>len(sequence) \u8fd4\u56desequence\u7684\u957f\u5ea6\uff0c\u4e3a\u6574\u578b\u7c7b\u578b<\/p>\n\n\n\n<p>sorted(iter, key, reverse) \u8fd4\u56de\u53ef\u8fed\u4ee3\u5bf9\u8c61iter\u6392\u5e8f\u540e\u7684\u5217\u8868\uff0ckey\u7528\u6765\u6307\u5b9a\u6392\u5e8f\u7684\u89c4\u5219\uff0creverse\u7528\u6765\u6307\u5b9a\u987a\u5e8f\u8fd8\u662f\u9006\u5e8f\u6392\u5217<\/p>\n\n\n\n<p>reversed(sequence) \u8fd4\u56de\u5e8f\u5217sequence\u9006\u5e8f\u6392\u5217\u540e\u7684\u8fed\u4ee3\u5668<\/p>\n\n\n\n<p>sum(iter, start) \u5c06iter\u4e2d\u7684\u6570\u503c\u548cstart\u53c2\u6570\u7684\u503c\u76f8\u52a0\uff0c\u8fd4\u56defloat\u7c7b\u578b\u6570\u503c<\/p>\n\n\n\n<p>max(iter) \u8fd4\u56de\u53ef\u8fed\u4ee3\u5bf9\u8c61iter\u4e2d\u7684\u6700\u5927\u503c<\/p>\n\n\n\n<p>min(iter) \u8fd4\u56de\u53ef\u8fed\u4ee3\u5bf9\u8c61iter\u4e2d\u7684\u6700\u5c0f\u503c<\/p>\n\n\n\n<p>enumerate(iter[, start]) \u8fd4\u56de\u4e00\u4e2aenumerate\u5bf9\u8c61\uff0c\u53ef\u751f\u6210\u4e00\u4e2a\u8fed\u4ee3\u5668\uff0c\u8be5\u8fed\u4ee3\u5668\u7684\u5143\u7d20\u662f\u7531\u53c2\u6570iter\u5143\u7d20\u7684\u7d22\u5f15\u548c\u503c\u7ec4\u6210\u7684\u5143\u7ec4<\/p>\n\n\n\n<p>zip(iter1 [,iter2 [&#8230;]]) \u8fd4\u56de\u4e00\u4e2azip\u5bf9\u8c61\uff0c\u53ef\u751f\u6210\u4e00\u4e2a\u8fed\u4ee3\u5668\uff0c\u8be5\u8fed\u4ee3\u5668\u7684\u7b2cn\u4e2a\u5143\u7d20\u662f\u6bcf\u4e2a\u53ef\u8fed\u4ee3\u5bf9\u8c61\u7684\u7b2cn\u4e2a\u5143\u7d20\u7ec4\u6210\u7684\u5143\u7ec4<\/p>\n\n\n\n<p><strong>2.\u5b57\u7b26\u4e32<\/strong><\/p>\n\n\n\n<p><strong>\u5b57\u7b26\u4e32\u5e38\u7528\u65b9\u6cd5<\/strong><\/p>\n\n\n\n<p>\u65b9\u6cd5 \u63cf\u8ff0<\/p>\n\n\n\n<p>s.capitalize() \u8fd4\u56de\u5b57\u7b26\u4e32s\u9996\u5b57\u6bcd\u5927\u5199\u5176\u4f59\u5c0f\u5199\u7684\u5f62\u5f0f<\/p>\n\n\n\n<p>s.lower() \u8fd4\u56de\u5b57\u7b26\u4e32s\u7684\u5c0f\u5199\u5f62\u5f0f<\/p>\n\n\n\n<p>s.upper() \u8fd4\u56de\u5b57\u7b26\u4e32s\u7684\u5927\u5199\u5f62\u5f0f<\/p>\n\n\n\n<p>s.title() \u8fd4\u56de\u5b57\u7b26\u4e32s\u7684\u6807\u9898\u5f62\u5f0f\u5373\u5355\u8bcd\u9996\u5b57\u6bcd\u5927\u5199\u5f62\u5f0f<\/p>\n\n\n\n<p>s.format(*args, **kwargs) \u683c\u5f0f\u5316\u5b57\u7b26\u4e32\u64cd\u4f5c<\/p>\n\n\n\n<p>s.count(sub[, start[, end]]) \u8fd4\u56de\u6307\u5b9a\u5b57\u7b26\u5728[\u6307\u5b9a\u4f4d\u7f6e\u7684]\u5b57\u7b26\u4e32s\u4e2d\u51fa\u73b0\u7684\u6b21\u6570<\/p>\n\n\n\n<p>s.find(sub[, start[, end]]) \u8fd4\u56de\u6307\u5b9a\u5b57\u7b26\u5728[\u6307\u5b9a\u4f4d\u7f6e\u7684]\u5b57\u7b26\u4e32s\u4e2d\u51fa\u73b0\u7684\u7d22\u5f15\u53f7\uff0c\u627e\u4e0d\u5230\u5219\u8fd4\u56de-1<\/p>\n\n\n\n<p>s.index(sub[, start[, end]]) \u4e0e find()\u7c7b\u4f3c\uff0c\u4e0d\u540c\u7684\u662f\u5982\u679c\u627e\u4e0d\u5230\u4f1a\u5f15\u53d1ValueError\u5f02\u5e38<\/p>\n\n\n\n<p>s.replace(old, new[, count]) \u628a\u5b57\u7b26\u4e32s\u4e2d\u7684old\uff08\u65e7\u5b57\u7b26\u4e32\uff09\u66ff\u6362\u6210new\uff08\u65b0\u5b57\u7b26\u4e32\uff09\u3002\u5982\u679c\u6307\u5b9a\u7b2c\u4e09\u4e2a\u53c2\u6570count\uff0c\u5219\u4ec5\u4ec5\u66ff\u6362\u524dcount\u6b21\u51fa\u73b0\u7684\u5b50\u4e32<\/p>\n\n\n\n<p>s.lstrip([chars]) \u79fb\u9664\u5b57\u7b26\u4e32s\u5de6\u8fb9\u7684\u6307\u5b9a\u5b57\u7b26\uff08\u9ed8\u8ba4\u4e3a\u5305\u62ec\u7a7a\u683c\u548c\u6362\u884c\u7b26\u7b49\u7684\u7a7a\u767d\u5b57\u7b26\uff09\uff0c\u8fd4\u56de\u79fb\u9664\u5b57\u7b26\u4e32s\u5de6\u8fb9\u6307\u5b9a\u5b57\u7b26\u540e\u751f\u6210\u7684\u65b0\u5b57\u7b26\u4e32<\/p>\n\n\n\n<p>s.rstrip([chars]) \u79fb\u9664\u5b57\u7b26\u4e32s\u672b\u5c3e\u7684\u6307\u5b9a\u5b57\u7b26\uff08\u9ed8\u8ba4\u4e3a\u5305\u62ec\u7a7a\u683c\u548c\u6362\u884c\u7b26\u7b49\u7684\u7a7a\u767d\u5b57\u7b26\uff09\uff0c\u8fd4\u56de\u79fb\u9664\u5b57\u7b26\u4e32s\u672b\u5c3e\u6307\u5b9a\u5b57\u7b26\u540e\u751f\u6210\u7684\u65b0\u5b57\u7b26\u4e32<\/p>\n\n\n\n<p>s.strip([chars]) \u79fb\u9664\u5b57\u7b26\u4e32s\u5934\u5c3e\u6307\u5b9a\u7684\u5b57\u7b26\uff08\u9ed8\u8ba4\u4e3a\u5305\u62ec\u7a7a\u683c\u548c\u6362\u884c\u7b26\u7b49\u7684\u7a7a\u767d\u5b57\u7b26\uff09\uff0c\u8fd4\u56de\u79fb\u9664\u5b57\u7b26\u4e32s\u5934\u5c3e\u6307\u5b9a\u5b57\u7b26\u540e\u751f\u6210\u7684\u65b0\u5b57\u7b26\u4e32<\/p>\n\n\n\n<p>s.join(iterable) \u7528\u6307\u5b9a\u7684\u5b57\u7b26\u4e32s\u8fde\u63a5\u5143\u7d20\u4e3a\u5b57\u7b26\u4e32\u7684\u53ef\u8fed\u4ee3\u5bf9\u8c61<\/p>\n\n\n\n<p>s.split(sep=None, maxsplit=-1) \u4ee5\u6307\u5b9a\u7684\u5b57\u7b26\u4f5c\u4e3a\u5206\u9694\u7b26\uff08\u9ed8\u8ba4\u4e3a\u5305\u62ec\u7a7a\u683c\u548c\u6362\u884c\u7b26\u7b49\u7684\u7a7a\u767d\u5b57\u7b26\uff09\u5206\u5272\u5b57\u7b26\u4e32s\uff0cmaxsplit\u6307\u5206\u5272\u6b21\u6570\uff08\u9ed8\u8ba4\u4e3a\u4e0d\u9650\u5236\u6b21\u6570\uff09<\/p>\n\n\n\n<p>s.endswith(suffix[, start[, end]]) \u5224\u65ad\u5b57\u7b26\u4e32s[\u7684\u6307\u5b9a\u4f4d\u7f6e]\u662f\u5426\u4ee5\u540e\u7f00suffix\u7ed3\u5c3e<\/p>\n\n\n\n<p>s.startswith(prefix[, start[, end]]) \u5224\u65ad\u5b57\u7b26\u4e32s[\u7684\u6307\u5b9a\u4f4d\u7f6e]\u662f\u5426\u4ee5\u524d\u7f00prefix\u5f00\u5934<\/p>\n\n\n\n<p><strong>3.\u5217\u8868<\/strong><\/p>\n\n\n\n<p><strong>\u5217\u8868\u5e38\u7528\u65b9\u6cd5<\/strong><\/p>\n\n\n\n<p>\u65b9\u6cd5 \u63cf\u8ff0<\/p>\n\n\n\n<p>l.append(obj) \u5728\u5217\u8868l\u672b\u5c3e\u6dfb\u52a0\u65b0\u7684\u5bf9\u8c61<\/p>\n\n\n\n<p>l.count(obj) \u7edf\u8ba1\u67d0\u4e2a\u5143\u7d20\u5728\u5217\u8868l\u4e2d\u51fa\u73b0\u7684\u6b21\u6570<\/p>\n\n\n\n<p>l.extend(seq) \u5728\u5217\u8868l\u672b\u5c3e\u4e00\u6b21\u6027\u8ffd\u52a0\u53e6\u4e00\u4e2a\u5e8f\u5217seq\u4e2d\u7684\u591a\u4e2a\u503c(\u7528\u65b0\u5217\u8868\u6269\u5c55\u539f\u6765\u7684\u5217\u8868)<\/p>\n\n\n\n<p>l.index(obj) \u4ece\u5217\u8868l\u4e2d\u627e\u51fa\u67d0\u4e2a\u503c\u7b2c\u4e00\u4e2a\u5339\u914d\u9879\u7684\u7d22\u5f15\u4f4d\u7f6e\uff0c\u7d22\u5f15\u4ece0\u5f00\u59cb<\/p>\n\n\n\n<p>l.insert(index, obj) \u5c06\u5bf9\u8c61obj\u63d2\u5165\u5217\u8868l\u4e2d\u7d22\u5f15\u4e3aindex\u7684\u5143\u7d20\u524d<\/p>\n\n\n\n<p>l.pop(index) \u79fb\u9664\u5217\u8868l\u4e2d\u7d22\u5f15\u4e3aindex\u7684\u4e00\u4e2a\u5143\u7d20(\u9ed8\u8ba4\u4e3a\u6700\u540e\u4e00\u4e2a\u5143\u7d20)\uff0c\u5e76\u4e14\u8fd4\u56de\u8be5\u5143\u7d20\u7684\u503c<\/p>\n\n\n\n<p>l.remove(obj) \u79fb\u9664\u5217\u8868l\u4e2d\u67d0\u4e2a\u503c\u7684\u7b2c\u4e00\u4e2a\u5339\u914d\u9879<\/p>\n\n\n\n<p>l.reverse() \u5c06\u5217\u8868l\u4e2d\u7684\u5143\u7d20\u53cd\u8f6c<\/p>\n\n\n\n<p>l.sort(key=None, reverse=False) \u5bf9\u539f\u5217\u8868l\u8fdb\u884c\u6392\u5e8f\uff0c\u53ef\u901a\u8fc7\u53c2\u6570key\u6307\u5b9a\u6392\u5e8f\u4f9d\u636e\uff0c\u901a\u8fc7\u53c2\u6570reverse\u6307\u5b9a\u987a\u5e8f\uff08\u9ed8\u8ba4\u65b9\u5f0f\uff09\u6216\u9006\u5e8f\u6392\u5217<\/p>\n\n\n\n<p><strong>4.\u5143\u7ec4<\/strong><\/p>\n\n\n\n<p><strong>\u5143\u7ec4\u5e38\u7528\u51fd\u6570<\/strong><\/p>\n\n\n\n<p>\u51fd\u6570 \u63cf\u8ff0<\/p>\n\n\n\n<p>len(t) \u8ba1\u7b97\u5143\u7ec4t\u7684\u5143\u7d20\u4e2a\u6570<\/p>\n\n\n\n<p>max(t) \u8fd4\u56de\u5143\u7ec4t\u4e2d\u5143\u7d20\u7684\u6700\u5927\u503c<\/p>\n\n\n\n<p>min(t) \u8fd4\u56de\u5143\u7ec4t\u4e2d\u5143\u7d20\u7684\u6700\u5c0f\u503c<\/p>\n\n\n\n<p>tuple(seq) \u5c06\u5e8f\u5217seq\u8f6c\u6362\u4e3a\u5143\u7ec4<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1.\u5e8f\u5217 (1) \u5e8f\u5217\u7684\u6807\u51c6\u7c7b\u578b\u8fd0\u7b97 &lt;\u3001&gt;\u3001&lt;=\u3001&gt;= <span class=\"readmore\"><a href=\"http:\/\/g1n29wqq.ipyingshe.net:5347\/?p=2531\">Continue Reading<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,10],"tags":[],"class_list":["post-2531","post","type-post","status-publish","format-standard","hentry","category-2","category-python"],"_links":{"self":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/2531","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2531"}],"version-history":[{"count":0,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/2531\/revisions"}],"wp:attachment":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2531"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2531"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2531"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}