#coding:utf-8
"""
字符串查找和替换
startswith
endswith
find
replace
"""
s='hello world'
# 1。 是否开始bool
print s.startswith('h')
# 2。 是否结尾bool
print s.endswith('ld')
# 3。 查找,找不到不报错,而是-1
print s.find('fuc')
print s.find('abc')
# 4。 替换,不会修改原字符串
s1=s.replace('world','python')
print s1
print s
Python学习-字符串查找和替换方法
猜你喜欢
转载自blog.csdn.net/weixin_38892128/article/details/85795129
今日推荐
周排行