burpow
字符串内建函数

字符串内建函数

split()

语法:

1
str.split(str="", num=string.count(str))

举例:

1
2
3
4
str = "this is string example....wow!!!"
print (str.split()) # 默认以空格为分隔符
print (str.split('i',1)) # 以 i 为分隔符
print (str.split('w')) # 以 w 为分隔符

输出结果:

1
2
3
['this', 'is', 'string', 'example....wow!!!']
['th', 's is string example....wow!!!']
['this is string example....', 'o', '!!!']

==接收字符串,返回列表==

isalpha()等

判断字符组成:

format()

详见[[python语法(下)#Python3 输入和输出#输出格式美化]]

本文作者:burpow
本文链接:https://youthfulnesszxx.github.io/2026/03/26/字符串内建函数/
版权声明:本文采用 CC BY-NC-SA 3.0 CN 协议进行许可