s = input() # 输入一个英文字符串
print(s.upper()) # 将字符串中所有英文字符转为大写输出
print(s.lower()) # 将字符串中所有英文字符转为小写输出
t = s.split(' ') # 将输入的字符串根据空格切分为列表,命名为t,每个单词为一个元素
print(t) # 输出切分的列表
print(' '.join(t)) # 将列表t中的元素用空格连接后输出
# 将列表t中的元素用连字符“-”连接后输出
print('/'.join(t)) # 将列表t中的元素用'/'连接后输出
print(s.find('the')) # 搜索字符串s中是否存在字符串'the',如存在返回其位置序号
r = s.replace('the', 'a') # 将字符串s中所有的'the'替换为'a',替换后的字符串重新命名为r
print(r) # 输出替换后的字符串r
r = s.replace('the', 'a', 1) # 将字符串s中的第一个'the'替换为'a',替换后的字符串重新命名为r
print(r) # 输出替换后的字符串r
"""
str.upper()
转换字符串str中所有字母为大写
str.lower()
转换字符串str中所有字母为小写
str.strip()
用于移除字符串头尾指定的字符(缺省时去掉空字符,包括\t、\n、\r、\x0b、\x0c等)
str.split()
通过指定分隔符对字符串进行切片,将一个字符串分裂成多个字符串列表,缺省时根据空格切分,可指定逗号或制表符等。
str.join(seq)
以字符串str作为分隔符,将序列 seq 中所有的元素合并为一个新的字符串
str.find()
搜索指定字符串
str.replace(old, new[, count])
把字符串str中的 old 替换成 new,如果 count 指定,则替换不超过 count 次,否则有多个old子串时全部替换为new。
for <var> in <string>
字符串迭代,如果var在string中存在,则进行循环
"""
12-07
1028
02-23
205
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交