Python基础7:字符串

1  * 重复输出字符串
print('helo '*4)
2  [],[:] 通过索引获取字符串中的字符,这里和列表中的切片操作是相同的,具体内容见列表
print('hello word'[2:])
3  in 成员运算符 - 如果字符串中包含指定的字符返回True
print('el' in 'hello')
4  格式字符串
print('%s is a super hero'%'lron man')
5  + 字符串拼接
a,b,c = 'one','two','three'
print(a+b+c)    #效率低
d = ''.join([a,b,c])
print(d)

猜你喜欢

转载自www.cnblogs.com/CatdeXin/p/10251174.html