{"id":1022,"date":"2023-03-24T09:47:07","date_gmt":"2023-03-24T01:47:07","guid":{"rendered":""},"modified":"2023-03-24T09:47:07","modified_gmt":"2023-03-24T01:47:07","slug":"Python \u5b57\u7b26\u4e32","status":"publish","type":"post","link":"https:\/\/bianchenghao6.com\/1022.html","title":{"rendered":"Python \u5b57\u7b26\u4e32"},"content":{"rendered":"


\n <\/head>
\n <\/p>\n

\n

Python \u5b57\u7b26\u4e32<\/h1>\n

\u641e\u61c2Python\u5b57\u7b26\u4e32\u7684\u7528\u6cd5<\/span>\n <\/div>\n

\n \u5b57\u7b26\u4e32\u5fc5\u987b\u7531\u53cc\u5f15\u53f7\" \"\u6216\u8005\u5355\u5f15\u53f7' '\u5305\u56f4\uff0c\u4f8b\u5982\uff1a
\n
str1 = 'Hello'
\n
str2 = \"World\"\n <\/div>\n
\n \u5b57\u7b26\u4e32\u7684\u5185\u5bb9\u53ef\u4ee5\u5305\u542b\u5b57\u6bcd\u3001\u6570\u5b57\u3001\u6807\u70b9\u3001\u7b26\u53f7\u3001\u4e2d\u6587\u548c\u5916\u6587\u3002\n <\/div>\n

\u8bbf\u95ee\u5b57\u7b26\u4e32\u7684\u503c<\/h2>\n
\n Python \u8bbf\u95ee\u5b50\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u4f7f\u7528\u65b9\u62ec\u53f7\u6765\u622a\u53d6\u5b57\u7b26\u4e32\uff0c\u4f8b\u5982:\n <\/div>\n
\n
 str1 = 'Hello'<\/span>
str2 = \"lidehuo\"<\/span>
print(\"var1[0]: \", str1[0]<\/span>)
print(\"var2[1:5]: \", str2 [1:5]<\/span>) <\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u6267\u884c\u7ed3\u679c\uff1a\n <\/div>\n
\n
var1[0]: , H<\/span> \n
\nvar2[1:5]: , ideh<\/span><\/code><\/pre>\n<\/p><\/div>\n

\u5b57\u7b26\u4e32\u62fc\u63a5<\/h2>\n
\n \u5b57\u7b26\u4e32\u4e4b\u95f4\u53ef\u4ee5\u8fdb\u884c\u62fc\u63a5\uff0c\u4f8b\u5982\uff1a\n <\/div>\n
\n
 str = 'Hello World'<\/span>
print(str[:2] + 'lidehuo'<\/span>) <\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u6267\u884c\u7ed3\u679c\uff1a\n <\/div>\n
\n
Helidehuo<\/span> \n
<\/code><\/pre>\n<\/p><\/div>\n

\u5b57\u7b26\u4e32\u8f6c\u8bd1<\/h2>\n
\n \u5f53\u5b57\u7b26\u4e2d\u51fa\u73b0\u7279\u6b8a\u5b57\u7b26\u65f6\uff0c\u9700\u8981\u7528\u53cd\u659c\u6760(\\)\u8f6c\u4e49\u5b57\u7b26\u3002\u5982\u4e0b\u8868\uff1a\n <\/div>\n

\u5b57\u7b26\u4e32\u8fd0\u7b97\u7b26<\/h2>\n
\n \u4e0b\u8868\u4e3a\u5b57\u7b26\u4e32\u7684\u8fd0\u7b97\uff1a\n <\/div>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u8f6c\u4e49\u5b57\u7b26<\/td>\n \u63cf\u8ff0<\/td>\n<\/tr>\n
\\(\u5728\u884c\u5c3e\u65f6)<\/td>\n \u7eed\u884c\u7b26<\/td>\n<\/tr>\n
\\\\<\/td>\n \u53cd\u659c\u6760\u7b26\u53f7<\/td>\n<\/tr>\n
\\'<\/td>\n \u5355\u5f15\u53f7<\/td>\n<\/tr>\n
\\\"<\/td>\n \u53cc\u5f15\u53f7<\/td>\n<\/tr>\n
\\a<\/td>\n \u54cd\u94c3<\/td>\n<\/tr>\n
\\b<\/td>\n \u9000\u683c(Backspace)<\/td>\n<\/tr>\n
\\000<\/td>\n\u7a7a<\/td>\n<\/tr>\n
\\n<\/td>\n \u6362\u884c<\/td>\n<\/tr>\n
\\v<\/td>\n \u7eb5\u5411\u5236\u8868\u7b26<\/td>\n<\/tr>\n
\\t<\/td>\n \u6a2a\u5411\u5236\u8868\u7b26<\/td>\n<\/tr>\n
\\r<\/td>\n \u56de\u8f66<\/td>\n<\/tr>\n
\\f<\/td>\n \u6362\u9875<\/td>\n<\/tr>\n
\\oyy<\/td>\n\u516b\u8fdb\u5236\u6570\uff0cyy \u4ee3\u8868\u7684\u5b57\u7b26\uff0c\u4f8b\u5982\uff1a\\o12 \u4ee3\u8868\u6362\u884c\uff0c\u5176\u4e2d o \u662f\u5b57\u6bcd\uff0c\u4e0d\u662f\u6570\u5b57 0\u3002<\/td>\n<\/tr>\n
\\xyy<\/td>\n\u5341\u516d\u8fdb\u5236\u6570\uff0cyy\u4ee3\u8868\u7684\u5b57\u7b26\uff0c\u4f8b\u5982\uff1a\\x0a\u4ee3\u8868\u6362\u884c\u3002<\/td>\n<\/tr>\n
\\other<\/td>\n\u5176\u5b83\u7684\u5b57\u7b26\u4ee5\u666e\u901a\u683c\u5f0f\u8f93\u51fa\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n\n\n\n\n\n\n\n\n\n\n\n
\u64cd\u4f5c\u7b26<\/td>\n\u63cf\u8ff0<\/td>\n<\/tr>\n
+<\/td>\n \u5b57\u7b26\u4e32\u8fde\u63a5<\/td>\n<\/tr>\n
*<\/td>\n \u91cd\u590d\u8f93\u51fa\u5b57\u7b26\u4e32<\/td>\n<\/tr>\n
[]<\/td>\n \u901a\u8fc7\u7d22\u5f15\u83b7\u53d6\u5b57\u7b26\u4e32\u4e2d\u5b57\u7b26<\/td>\n<\/tr>\n
[ : ]<\/td>\n \u622a\u53d6\u5b57\u7b26\u4e32\u4e2d\u7684\u4e00\u90e8\u5206\uff0c\u9075\u5faa\u5de6\u95ed\u53f3\u5f00\u539f\u5219\uff0cstr[0:2] \u662f\u4e0d\u5305\u542b\u7b2c 3 \u4e2a\u5b57\u7b26\u7684\u3002<\/td>\n<\/tr>\n
in<\/td>\n \u6210\u5458\u8fd0\u7b97\u7b26 - \u5982\u679c\u5b57\u7b26\u4e32\u4e2d\u5305\u542b\u7ed9\u5b9a\u7684\u5b57\u7b26\u8fd4\u56de True<\/td>\n<\/tr>\n
not in<\/td>\n \u6210\u5458\u8fd0\u7b97\u7b26 - \u5982\u679c\u5b57\u7b26\u4e32\u4e2d\u4e0d\u5305\u542b\u7ed9\u5b9a\u7684\u5b57\u7b26\u8fd4\u56de True<\/td>\n<\/tr>\n
r\/R<\/td>\n \u539f\u59cb\u5b57\u7b26\u4e32\uff1a\u6240\u6709\u7684\u5b57\u7b26\u4e32\u90fd\u662f\u76f4\u63a5\u6309\u7167\u5b57\u9762\u7684\u610f\u601d\u6765\u4f7f\u7528\uff0c\u6ca1\u6709\u8f6c\u4e49\u7279\u6b8a\u6216\u4e0d\u80fd\u6253\u5370\u7684\u5b57\u7b26\u3002 \u539f\u59cb\u5b57\u7b26\u4e32\u9664\u5728\u5b57\u7b26\u4e32\u7684\u7b2c\u4e00\u4e2a\u5f15\u53f7\u524d\u52a0\u4e0a\u5b57\u6bcd r\uff08\u53ef\u4ee5\u5927\u5c0f\u5199\uff09\u4ee5\u5916\uff0c\u4e0e\u666e\u901a\u5b57\u7b26\u4e32\u6709\u7740\u51e0\u4e4e\u5b8c\u5168\u76f8\u540c\u7684\u8bed\u6cd5\u3002<\/td>\n<\/tr>\n
%<\/td>\n \u683c\u5f0f\u5b57\u7b26\u4e32<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\n
 a = \"Hello\"<\/span>
b = \"World\"<\/span>
print(\"a + b \u8f93\u51fa\u7ed3\u679c\uff1a\", a + b<\/span>)
print(\"a * 2 \u8f93\u51fa\u7ed3\u679c\uff1a\", a * 2<\/span>)
print(\"a[1] \u8f93\u51fa\u7ed3\u679c\uff1a\", a[1]<\/span>)
print(\"a[1:4] \u8f93\u51fa\u7ed3\u679c\uff1a\", a[1:4]<\/span>)
if<\/span> ( \"H\" in a ):
 print(\"H \u5728\u53d8\u91cf a \u4e2d\"<\/span>)
else:<\/span>
 print(\"H \u4e0d\u5728\u53d8\u91cf a \u4e2d\"<\/span>)
if<\/span> ( \"M\" not in a ):
 print(\"M \u4e0d\u5728\u53d8\u91cf a \u4e2d\"<\/span>)
else:<\/span>
 print(\"M \u5728\u53d8\u91cf a \u4e2d\"<\/span>)
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u6267\u884c\u7ed3\u679c\uff1a\n <\/div>\n
\n
a + b \u8f93\u51fa\u7ed3\u679c\uff1a HelloWorld<\/span> \n
\na * 2 \u8f93\u51fa\u7ed3\u679c\uff1a HelloHello<\/span> \n
\na[1] \u8f93\u51fa\u7ed3\u679c\uff1a e<\/span> \n
\na[1:4] \u8f93\u51fa\u7ed3\u679c\uff1a ell<\/span> \n
\nH \u5728\u53d8\u91cf a \u4e2d<\/span> \n
\nM \u4e0d\u5728\u53d8\u91cf a \u4e2d<\/span><\/code><\/pre>\n<\/p><\/div>\n

\u5b57\u7b26\u4e32\u683c\u5f0f\u5316<\/h2>\n
\n Python\u4e2d\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u4f7f\u7528\u683c\u5f0f\u5982\u4e0b\uff1a\n <\/div>\n
\n
 print(\"\u6211\u662f%s, \u6b22\u8fce\u5927\u5bb6\u5b66\u4e60%s \u6559\u7a0b.\" % ('\u7acb\u5730\u8d27','python')<\/span>) <\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u6267\u884c\u7ed3\u679c\uff1a\n <\/div>\n
\n
\u6211\u662f\u7acb\u5730\u8d27, \u6b22\u8fce\u5927\u5bb6\u5b66\u4e60python \u6559\u7a0b\u3002<\/span> \n
<\/code><\/pre>\n<\/p><\/div>\n
\n Python\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u7b26\u53f7:\n <\/div>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u7b26\u53f7<\/td>\n\u63cf\u8ff0<\/td>\n<\/tr>\n
%c<\/td>\n\u683c\u5f0f\u5316\u5b57\u7b26\u53ca\u5176ASCII\u7801<\/td>\n<\/tr>\n
%s<\/td>\n\u683c\u5f0f\u5316\u5b57\u7b26\u4e32<\/td>\n<\/tr>\n
%d<\/td>\n\u683c\u5f0f\u5316\u6574\u6570<\/td>\n<\/tr>\n
%u<\/td>\n\u683c\u5f0f\u5316\u65e0\u7b26\u53f7\u6574\u578b<\/td>\n<\/tr>\n
%o<\/td>\n\u683c\u5f0f\u5316\u65e0\u7b26\u53f7\u516b\u8fdb\u5236\u6570<\/td>\n<\/tr>\n
%x<\/td>\n\u683c\u5f0f\u5316\u65e0\u7b26\u53f7\u5341\u516d\u8fdb\u5236\u6570<\/td>\n<\/tr>\n
%X<\/td>\n\u683c\u5f0f\u5316\u65e0\u7b26\u53f7\u5341\u516d\u8fdb\u5236\u6570\uff08\u5927\u5199\uff09<\/td>\n<\/tr>\n
%f<\/td>\n\u683c\u5f0f\u5316\u6d6e\u70b9\u6570\u5b57\uff0c\u53ef\u6307\u5b9a\u5c0f\u6570\u70b9\u540e\u7684\u7cbe\u5ea6<\/td>\n<\/tr>\n
%e<\/td>\n\u7528\u79d1\u5b66\u8ba1\u6570\u6cd5\u683c\u5f0f\u5316\u6d6e\u70b9\u6570<\/td>\n<\/tr>\n
%E<\/td>\n\u4f5c\u7528\u540c%e\uff0c\u7528\u79d1\u5b66\u8ba1\u6570\u6cd5\u683c\u5f0f\u5316\u6d6e\u70b9\u6570<\/td>\n<\/tr>\n
%g<\/td>\n%f\u548c%e\u7684\u7b80\u5199<\/td>\n<\/tr>\n
%G<\/td>\n%f \u548c %E \u7684\u7b80\u5199<\/td>\n<\/tr>\n
%p<\/td>\n\u7528\u5341\u516d\u8fdb\u5236\u6570\u683c\u5f0f\u5316\u53d8\u91cf\u7684\u5730\u5740<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\n \u683c\u5f0f\u5316\u64cd\u4f5c\u7b26\u8f85\u52a9\u6307\u4ee4:\n <\/div>\n\n\n\n\n\n\n\n\n\n\n\n\n
\u7b26\u53f7<\/td>\n\u529f\u80fd<\/td>\n<\/tr>\n
*<\/td>\n\u5b9a\u4e49\u5bbd\u5ea6\u6216\u8005\u5c0f\u6570\u70b9\u7cbe\u5ea6<\/td>\n<\/tr>\n
-<\/td>\n\u7528\u505a\u5de6\u5bf9\u9f50<\/td>\n<\/tr>\n
+<\/td>\n\u5728\u6b63\u6570\u524d\u9762\u663e\u793a\u52a0\u53f7( + )<\/td>\n<\/tr>\n
<sp><\/td>\n\u5728\u6b63\u6570\u524d\u9762\u663e\u793a\u7a7a\u683c<\/td>\n<\/tr>\n
# <\/td>\n\u5728\u516b\u8fdb\u5236\u6570\u524d\u9762\u663e\u793a\u96f6('0')\uff0c\u5728\u5341\u516d\u8fdb\u5236\u524d\u9762\u663e\u793a'0x'\u6216\u8005'0X'(\u53d6\u51b3\u4e8e\u7528\u7684\u662f'x'\u8fd8\u662f'X')<\/td>\n<\/tr>\n
0 <\/td>\n\u663e\u793a\u7684\u6570\u5b57\u524d\u9762\u586b\u5145'0'\u800c\u4e0d\u662f\u9ed8\u8ba4\u7684\u7a7a\u683c<\/td>\n<\/tr>\n
% <\/td>\n'%%'\u8f93\u51fa\u4e00\u4e2a\u5355\u4e00\u7684'%'<\/td>\n<\/tr>\n
(var) <\/td>\n\u6620\u5c04\u53d8\u91cf(\u5b57\u5178\u53c2\u6570)<\/td>\n<\/tr>\n
m.n. <\/td>\nm \u662f\u663e\u793a\u7684\u6700\u5c0f\u603b\u5bbd\u5ea6,n \u662f\u5c0f\u6570\u70b9\u540e\u7684\u4f4d\u6570(\u5982\u679c\u53ef\u7528\u7684\u8bdd)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u5b57\u7b26\u4e32\u6362\u884c<\/h2>\n
\n python\u4e2d\u4f7f\u7528\u4e09\u4e2a\u5355\u5f15\u53f7\u6216\u4e09\u4e2a\u53cc\u5f15\u53f7\u89e3\u51b3\u5b57\u7b26\u4e32\u8de8\u8de8\u884c\u95ee\u9898\uff0c\u4f8b\u5982\uff1a\n <\/div>\n
\n
 str = \"\"\"\u8fd9\u662f\u4e00\u4e2a\u591a\u884c\u5b57\u7b26\u4e32\u7684\u5b9e\u4f8b
\u591a\u884c\u5b57\u7b26\u4e32\u53ef\u4ee5\u4f7f\u7528\u5236\u8868\u7b26\uff0c
\u4e5f\u53ef\u4ee5\u4f7f\u7528\u6362\u884c\u7b26\u3002 \"\"\"
print(str<\/span>) <\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u6267\u884c\u7ed3\u679c\uff1a\n <\/div>\n
\n
\u8fd9\u662f\u4e00\u4e2a\u591a\u884c\u5b57\u7b26\u4e32\u7684\u5b9e\u4f8b
\u591a\u884c\u5b57\u7b26\u4e32\u53ef\u4ee5\u4f7f\u7528\u5236\u8868\u7b26\uff0c
\u4e5f\u53ef\u4ee5\u4f7f\u7528\u6362\u884c\u7b26\u3002<\/span><\/code><\/pre>\n<\/p><\/div>\n

\u5b57\u7b26\u4e32\u5185\u7f6e\u51fd\u6570<\/h2>\n
\n Python \u7684\u5b57\u7b26\u4e32\u5e38\u7528\u5185\u5efa\u51fd\u6570\u5982\u4e0b\uff1a\n <\/div>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u5e8f\u53f7<\/td>\n\u65b9\u6cd5\u53ca\u63cf\u8ff0<\/td>\n<\/tr>\n
1<\/td>\ncapitalize()
\u5c06\u5b57\u7b26\u4e32\u7684\u7b2c\u4e00\u4e2a\u5b57\u7b26\u8f6c\u6362\u4e3a\u5927\u5199<\/td>\n<\/tr>\n
2<\/td>\ncenter(width, fillchar)
\u8fd4\u56de\u4e00\u4e2a\u6307\u5b9a\u7684\u5bbd\u5ea6 width \u5c45\u4e2d\u7684\u5b57\u7b26\u4e32\uff0cfillchar \u4e3a\u586b\u5145\u7684\u5b57\u7b26\uff0c\u9ed8\u8ba4\u4e3a\u7a7a\u683c\u3002<\/td>\n<\/tr>\n
3<\/td>\ncount(str, beg= 0,end=len(string))
\u8fd4\u56de str \u5728 string \u91cc\u9762\u51fa\u73b0\u7684\u6b21\u6570\uff0c\u5982\u679c beg \u6216\u8005 end \u6307\u5b9a\u5219\u8fd4\u56de\u6307\u5b9a\u8303\u56f4\u5185 str \u51fa\u73b0\u7684\u6b21\u6570<\/td>\n<\/tr>\n
4<\/td>\nbytes.decode(encoding=\"utf-8\", errors=\"strict\")
Python3 \u4e2d\u6ca1\u6709 decode \u65b9\u6cd5\uff0c\u4f46\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 bytes \u5bf9\u8c61\u7684 decode() \u65b9\u6cd5\u6765\u89e3\u7801\u7ed9\u5b9a\u7684 bytes \u5bf9\u8c61\uff0c\u8fd9\u4e2a bytes \u5bf9\u8c61\u53ef\u4ee5\u7531 str.encode() \u6765\u7f16\u7801\u8fd4\u56de\u3002<\/td>\n<\/tr>\n
5<\/td>\nencode(encoding='UTF-8',errors='strict')
\u4ee5 encoding \u6307\u5b9a\u7684\u7f16\u7801\u683c\u5f0f\u7f16\u7801\u5b57\u7b26\u4e32\uff0c\u5982\u679c\u51fa\u9519\u9ed8\u8ba4\u62a5\u4e00\u4e2aValueError \u7684\u5f02\u5e38\uff0c\u9664\u975e errors \u6307\u5b9a\u7684\u662f'ignore'\u6216\u8005'replace'<\/td>\n<\/tr>\n
6<\/td>\nendswith(suffix, beg=0, end=len(string))
\u68c0\u67e5\u5b57\u7b26\u4e32\u662f\u5426\u4ee5 obj \u7ed3\u675f\uff0c\u5982\u679cbeg \u6216\u8005 end \u6307\u5b9a\u5219\u68c0\u67e5\u6307\u5b9a\u7684\u8303\u56f4\u5185\u662f\u5426\u4ee5 obj \u7ed3\u675f\uff0c\u5982\u679c\u662f\uff0c\u8fd4\u56de True,\u5426\u5219\u8fd4\u56de False.<\/td>\n<\/tr>\n
7<\/td>\nexpandtabs(tabsize=8)
\u628a\u5b57\u7b26\u4e32 string \u4e2d\u7684 tab \u7b26\u53f7\u8f6c\u4e3a\u7a7a\u683c\uff0ctab \u7b26\u53f7\u9ed8\u8ba4\u7684\u7a7a\u683c\u6570\u662f 8 \u3002<\/td>\n<\/tr>\n
8<\/td>\nfind(str, beg=0, end=len(string))
\u68c0\u6d4b str \u662f\u5426\u5305\u542b\u5728\u5b57\u7b26\u4e32\u4e2d\uff0c\u5982\u679c\u6307\u5b9a\u8303\u56f4 beg \u548c end \uff0c\u5219\u68c0\u67e5\u662f\u5426\u5305\u542b\u5728\u6307\u5b9a\u8303\u56f4\u5185\uff0c\u5982\u679c\u5305\u542b\u8fd4\u56de\u5f00\u59cb\u7684\u7d22\u5f15\u503c\uff0c\u5426\u5219\u8fd4\u56de-1\u3002<\/td>\n<\/tr>\n
9<\/td>\nindex(str, beg=0, end=len(string))
\u8ddffind()\u65b9\u6cd5\u4e00\u6837\uff0c\u53ea\u4e0d\u8fc7\u5982\u679cstr\u4e0d\u5728\u5b57\u7b26\u4e32\u4e2d\u4f1a\u62a5\u4e00\u4e2a\u5f02\u5e38\u3002<\/td>\n<\/tr>\n
10<\/td>\nisalnum()
\u5982\u679c\u5b57\u7b26\u4e32\u81f3\u5c11\u6709\u4e00\u4e2a\u5b57\u7b26\u5e76\u4e14\u6240\u6709\u5b57\u7b26\u90fd\u662f\u5b57\u6bcd\u6216\u6570\u5b57\u5219\u8fd4 \u56de True,\u5426\u5219\u8fd4\u56de False\u3002<\/td>\n<\/tr>\n
11<\/td>\nisalpha()
\u5982\u679c\u5b57\u7b26\u4e32\u81f3\u5c11\u6709\u4e00\u4e2a\u5b57\u7b26\u5e76\u4e14\u6240\u6709\u5b57\u7b26\u90fd\u662f\u5b57\u6bcd\u5219\u8fd4\u56de True, \u5426\u5219\u8fd4\u56de False\u3002<\/td>\n<\/tr>\n
12<\/td>\nisdigit()
\u5982\u679c\u5b57\u7b26\u4e32\u53ea\u5305\u542b\u6570\u5b57\u5219\u8fd4\u56de True \u5426\u5219\u8fd4\u56de False\u3002<\/td>\n<\/tr>\n
13<\/td>\nislower()
\u5982\u679c\u5b57\u7b26\u4e32\u4e2d\u5305\u542b\u81f3\u5c11\u4e00\u4e2a\u533a\u5206\u5927\u5c0f\u5199\u7684\u5b57\u7b26\uff0c\u5e76\u4e14\u6240\u6709\u8fd9\u4e9b(\u533a\u5206\u5927\u5c0f\u5199\u7684)\u5b57\u7b26\u90fd\u662f\u5c0f\u5199\uff0c\u5219\u8fd4\u56de True\uff0c\u5426\u5219\u8fd4\u56de False\u3002<\/td>\n<\/tr>\n
14<\/td>\nisnumeric()
\u5982\u679c\u5b57\u7b26\u4e32\u4e2d\u53ea\u5305\u542b\u6570\u5b57\u5b57\u7b26\uff0c\u5219\u8fd4\u56de True\uff0c\u5426\u5219\u8fd4\u56de False\u3002<\/td>\n<\/tr>\n
15<\/td>\nisspace()
\u5982\u679c\u5b57\u7b26\u4e32\u4e2d\u53ea\u5305\u542b\u7a7a\u767d\uff0c\u5219\u8fd4\u56de True\uff0c\u5426\u5219\u8fd4\u56de False\u3002<\/td>\n<\/tr>\n
16<\/td>\nistitle()
\u5982\u679c\u5b57\u7b26\u4e32\u662f\u6807\u9898\u5316\u7684(\u89c1 title())\u5219\u8fd4\u56de True\uff0c\u5426\u5219\u8fd4\u56de False\u3002<\/td>\n<\/tr>\n
17<\/td>\nisupper()
\u5982\u679c\u5b57\u7b26\u4e32\u4e2d\u5305\u542b\u81f3\u5c11\u4e00\u4e2a\u533a\u5206\u5927\u5c0f\u5199\u7684\u5b57\u7b26\uff0c\u5e76\u4e14\u6240\u6709\u8fd9\u4e9b(\u533a\u5206\u5927\u5c0f\u5199\u7684)\u5b57\u7b26\u90fd\u662f\u5927\u5199\uff0c\u5219\u8fd4\u56de True\uff0c\u5426\u5219\u8fd4\u56de False\u3002<\/td>\n<\/tr>\n
18<\/td>\njoin(seq)
\u4ee5\u6307\u5b9a\u5b57\u7b26\u4e32\u4f5c\u4e3a\u5206\u9694\u7b26\uff0c\u5c06 seq \u4e2d\u6240\u6709\u7684\u5143\u7d20(\u7684\u5b57\u7b26\u4e32\u8868\u793a)\u5408\u5e76\u4e3a\u4e00\u4e2a\u65b0\u7684\u5b57\u7b26\u4e32\u3002<\/td>\n<\/tr>\n
19<\/td>\nlen(string)
\u8fd4\u56de\u5b57\u7b26\u4e32\u957f\u5ea6\u3002<\/td>\n<\/tr>\n
20<\/td>\nljust(width[, fillchar])
\u8fd4\u56de\u4e00\u4e2a\u539f\u5b57\u7b26\u4e32\u5de6\u5bf9\u9f50,\u5e76\u4f7f\u7528 fillchar \u586b\u5145\u81f3\u957f\u5ea6 width \u7684\u65b0\u5b57\u7b26\u4e32\uff0cfillchar \u9ed8\u8ba4\u4e3a\u7a7a\u683c\u3002<\/td>\n<\/tr>\n
21<\/td>\nlower()
\u8f6c\u6362\u5b57\u7b26\u4e32\u4e2d\u6240\u6709\u5927\u5199\u5b57\u7b26\u4e3a\u5c0f\u5199\u3002<\/td>\n<\/tr>\n
22<\/td>\nlstrip()
\u622a\u6389\u5b57\u7b26\u4e32\u5de6\u8fb9\u7684\u7a7a\u683c\u6216\u6307\u5b9a\u5b57\u7b26\u3002<\/td>\n<\/tr>\n
23<\/td>\nmaketrans()
\u521b\u5efa\u5b57\u7b26\u6620\u5c04\u7684\u8f6c\u6362\u8868\uff0c\u5bf9\u4e8e\u63a5\u53d7\u4e24\u4e2a\u53c2\u6570\u7684\u6700\u7b80\u5355\u7684\u8c03\u7528\u65b9\u5f0f\uff0c\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f\u5b57\u7b26\u4e32\uff0c\u8868\u793a\u9700\u8981\u8f6c\u6362\u7684\u5b57\u7b26\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u4e5f\u662f\u5b57\u7b26\u4e32\u8868\u793a\u8f6c\u6362\u7684\u76ee\u6807\u3002<\/td>\n<\/tr>\n
24<\/td>\nmax(str)
\u8fd4\u56de\u5b57\u7b26\u4e32 str \u4e2d\u6700\u5927\u7684\u5b57\u6bcd\u3002<\/td>\n<\/tr>\n
25<\/td>\nmin(str)
\u8fd4\u56de\u5b57\u7b26\u4e32 str \u4e2d\u6700\u5c0f\u7684\u5b57\u6bcd\u3002<\/td>\n<\/tr>\n
26 <\/td>\nreplace(old, new [, max])
\u628a \u5c06\u5b57\u7b26\u4e32\u4e2d\u7684 str1 \u66ff\u6362\u6210 str2,\u5982\u679c max \u6307\u5b9a\uff0c\u5219\u66ff\u6362\u4e0d\u8d85\u8fc7 max \u6b21\u3002<\/td>\n<\/tr>\n
27<\/td>\nrfind(str, beg=0,end=len(string))
\u7c7b\u4f3c\u4e8e find()\u51fd\u6570\uff0c\u4e0d\u8fc7\u662f\u4ece\u53f3\u8fb9\u5f00\u59cb\u67e5\u627e\u3002<\/td>\n<\/tr>\n
28<\/td>\nrindex( str, beg=0, end=len(string))
\u7c7b\u4f3c\u4e8e index()\uff0c\u4e0d\u8fc7\u662f\u4ece\u53f3\u8fb9\u5f00\u59cb\u3002<\/td>\n<\/tr>\n
29<\/td>\nrjust(width,[, fillchar])
\u8fd4\u56de\u4e00\u4e2a\u539f\u5b57\u7b26\u4e32\u53f3\u5bf9\u9f50,\u5e76\u4f7f\u7528fillchar(\u9ed8\u8ba4\u7a7a\u683c\uff09\u586b\u5145\u81f3\u957f\u5ea6 width \u7684\u65b0\u5b57\u7b26\u4e32\u3002<\/td>\n<\/tr>\n
30<\/td>\nrstrip()
\u5220\u9664\u5b57\u7b26\u4e32\u5b57\u7b26\u4e32\u672b\u5c3e\u7684\u7a7a\u683c\u3002<\/td>\n<\/tr>\n
31<\/td>\nsplit(str=\"\", num=string.count(str))
num=string.count(str)) \u4ee5 str \u4e3a\u5206\u9694\u7b26\u622a\u53d6\u5b57\u7b26\u4e32\uff0c\u5982\u679c num \u6709\u6307\u5b9a\u503c\uff0c\u5219\u4ec5\u622a\u53d6 num+1 \u4e2a\u5b50\u5b57\u7b26\u4e32\u3002<\/td>\n<\/tr>\n
32<\/td>\nsplitlines([keepends])
\u6309\u7167\u884c('\\r', '\\r\\n', \\n')\u5206\u9694\uff0c\u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u5404\u884c\u4f5c\u4e3a\u5143\u7d20\u7684\u5217\u8868\uff0c\u5982\u679c\u53c2\u6570 keepends \u4e3a False\uff0c\u4e0d\u5305\u542b\u6362\u884c\u7b26\uff0c\u5982\u679c\u4e3a True\uff0c\u5219\u4fdd\u7559\u6362\u884c\u7b26\u3002<\/td>\n<\/tr>\n
33<\/td>\nstartswith(substr, beg=0,end=len(string))
\u68c0\u67e5\u5b57\u7b26\u4e32\u662f\u5426\u662f\u4ee5\u6307\u5b9a\u5b50\u5b57\u7b26\u4e32 substr \u5f00\u5934\uff0c\u662f\u5219\u8fd4\u56de True\uff0c\u5426\u5219\u8fd4\u56de False\u3002\u5982\u679cbeg \u548c end \u6307\u5b9a\u503c\uff0c\u5219\u5728\u6307\u5b9a\u8303\u56f4\u5185\u68c0\u67e5\u3002<\/td>\n<\/tr>\n
34<\/td>\nstrip([chars])
\u5728\u5b57\u7b26\u4e32\u4e0a\u6267\u884c lstrip()\u548c rstrip()\u3002<\/td>\n<\/tr>\n
35<\/td>\nswapcase()
\u5c06\u5b57\u7b26\u4e32\u4e2d\u5927\u5199\u8f6c\u6362\u4e3a\u5c0f\u5199\uff0c\u5c0f\u5199\u8f6c\u6362\u4e3a\u5927\u5199\u3002<\/td>\n<\/tr>\n
36<\/td>\ntitle()
\u8fd4\u56de\"\u6807\u9898\u5316\"\u7684\u5b57\u7b26\u4e32,\u5c31\u662f\u8bf4\u6240\u6709\u5355\u8bcd\u90fd\u662f\u4ee5\u5927\u5199\u5f00\u59cb\uff0c\u5176\u4f59\u5b57\u6bcd\u5747\u4e3a\u5c0f\u5199(\u89c1 istitle())\u3002<\/td>\n<\/tr>\n
37<\/td>\ntranslate(table, deletechars=\"\")
\u6839\u636e str \u7ed9\u51fa\u7684\u8868(\u5305\u542b 256 \u4e2a\u5b57\u7b26)\u8f6c\u6362 string \u7684\u5b57\u7b26, \u8981\u8fc7\u6ee4\u6389\u7684\u5b57\u7b26\u653e\u5230 deletechars \u53c2\u6570\u4e2d\u3002<\/td>\n<\/tr>\n
38<\/td>\nupper()
\u8f6c\u6362\u5b57\u7b26\u4e32\u4e2d\u7684\u5c0f\u5199\u5b57\u6bcd\u4e3a\u5927\u5199\u3002<\/td>\n<\/tr>\n
39<\/td>\nzfill(width)
\u8fd4\u56de\u957f\u5ea6\u4e3a width \u7684\u5b57\u7b26\u4e32\uff0c\u539f\u5b57\u7b26\u4e32\u53f3\u5bf9\u9f50\uff0c\u524d\u9762\u586b\u51450\u3002<\/td>\n<\/tr>\n
40<\/td>\nisdecimal()
\u68c0\u67e5\u5b57\u7b26\u4e32\u662f\u5426\u53ea\u5305\u542b\u5341\u8fdb\u5236\u5b57\u7b26\uff0c\u5982\u679c\u662f\u8fd4\u56de true\uff0c\u5426\u5219\u8fd4\u56de false\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

<\/body>
\n<\/html><\/p>\n","protected":false},"excerpt":{"rendered":"Python \u5b57\u7b26\u4e32zh-cn","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[126],"tags":[],"class_list":["post-1022","post","type-post","status-publish","format-standard","hentry","category-python3"],"_links":{"self":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/1022"}],"collection":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/comments?post=1022"}],"version-history":[{"count":0,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/1022\/revisions"}],"wp:attachment":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/media?parent=1022"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/categories?post=1022"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/tags?post=1022"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}