"""
字符串小练习
"""
'''
修改
'''
st = "Hello World"
st1 = st.upper()
st2 = st.lower()
st3 = st2.capitalize()
st4 = st3.title()
li = st.split()
'''
查询
'''
print(st.count('l'))
print(st.find('W', 0, -1))
print(st.index('ll', 0, -1))
print(st.isdigit())
print(st.isalpha())
print(st.endswith('d'))
print(st.startswith('H'))
print(st.islower())
print(st.isupper())
'''
获取(切片)
可以采用[N: M]格式获取字符串的子串,
这个操作 被形象地称为切片。
[N: M]获取字符串中从N到M (但不包含M)间连续的子字符串。
格式:
<字符串或字符串变量>[N: M]
'''
st5 = st[0:5]
'''
替换
后一个元素替换前一个元素
'''
st6 = st.replace('H', 'h', 1)
st7 = st[::-1]