1增

str1 = "shi"
str2 = "bei"
str3 = str1 + str2

 

2删

str1 = ""

  

3改

str1.upper()
str1.lower()
str1.capitalize()
str1.strip()
email = 'de8ug#foxmail.com'
email.replace('#','@')    #email.replace(old,new) 结果:'de8ug@foxmail.com'
email.split('#')        #去除分隔符,变成列表 结果:['de8ug', 'foxmail.com']

 

4查

'de8ug'.count('8') #查看某个字符出现的次数  结果: 1
py = 'python is cool' 
py.index('is')   #查询在哪个位置
py = 'python2 python3 python4 python
py[3] 结果:'h'

 

5常用方法

'name: %s, place: %s'%(name,city)  结果:'name: de8ug, place: beijing'
'name:{},place:{}'.format(name,city)  结果:'name:de8ug,place:beijing'

 

posted on 2020-07-05 10:22  知否知否,  阅读(78)  评论(0编辑  收藏  举报