1、join 连接
s1 = 'dabai'
s2 = ':'.join(s1)
print(s2)
输出结果如下:
l1 = ['大白', '最帅', '最萌']
print(l1, type(l1))
l2 = ''.join(l1)
print(l2, type(l2))
l3 = '-'.join(l1)
print(l3)
2、isalnum(字符串由字母或数字组成) isalpha(字符串只由字母组成) isdecimal(字符串只由十进制组成)
isalnum
s1 = 'dabai123'
s2 = '123456'
s3 = '100①'
s4 = 'dabai*#'
s5 = 'dabai'
index = [s1, s2, s3, s4, s5]
for i in (index):
print(i.isalnum())
输出结果如下:
isalpha
s1 = 'dabai123'
s2 = '123456'
s3 = '100①'
s4 = 'dabai*#'
s5 = 'dabai'
index = [s1, s2, s3, s4, s5]
for i in (index):
print(i.isalpha())
输出结果如下:
isdecimal
s1 = 'dabai123'
s2 = '123456'
s3 = '100①'
s4 = 'dabai*#'
s5 = 'dabai'
index = [s1, s2, s3, s4, s5]
for i in (index):
print(i.isdecimal())
输出结果如下: 常用的大概就这些了!!!
|