判断和查询字符串和字符串的其他方法

s='hello,python'
print('1.',s.isidentifier())
#False 其中含有,不是合法的标识符
print('2.','hello'.isidentifier())
print('3','张三_'.isidentifier())
print('4.','张三_123'.isidentifier())#字母,数字,下划线都可以(张三属于字母)
#2. True
#3. True
#4. True
print('6.','abc'.isalpha())
print('7.','张三'.isalpha())
print('8.','张三1'.isalpha())
#6. True
#7. True
#8. False
print('9.','123'.isnumeric())
print('10.','123四Ⅳ④'.isnumeric())
#9. True
#10. True
s='hello,Python'
print(s)
print(s.replace('Python','java'))
#hello,Python
#hello,java
s1='hello,python,python,python'
print(s1)
print(s1.replace('python','java',2))
#hello,python,python,python
#hello,java,java,python
lst=['hello','java','python']
print('|'.join(lst))
print(''.join(lst))
#hello|java|python
#hellojavapython
t=('hello','java','python')
print(''.join(t))
#hellojavapython  元组,列表都可以
print('*'.join('python'))
#p*y*t*h*o*n

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值