学习第3天

dir (str)   显示所有类成员 

type()    获取类属性 

 

STR 内 方法 :

1 __add__

2__contains__      字符串中是否包含某个子项

3 __eq__   等于 

4__format__   格式化   

   

5__getattritute__      反射

6__getitem__

7__getnewargs__

8__gt__

9

10

11

12

13

 

1capitalize(self)     首字母大写

2casefold(self)  首字母变小写

3center(self,width,fillchar=None)        居中 

      name=liujun

      result=name.center(20,*)

      print(result)

4count(self,sub,start=None,end=None)    查找字符串中子项个数

5encode(self,encoding='utf-8',errors='strict' )

     name=李姐

     name.encode('gbk')    # 结果转换成gbk编码 ,   unicode   gbk   utf-8  

6endswith(self,suffix,start=None,end=None)

7expandtabs(self,tabsize=8)   tab转为空格 ,默认8个空格

8find(self,sub,start=None,end=None)    查找字符串中子项 ,返回所在起始位置,不存在返回-1

 功能 类似 index,没找到抛异常

9 format(*args,**kwargs)

 

     name=" liujun  {0}   is  {1}"

     result=name.format('boy','good')

     print(result)          #liujun  boy  is  good

10 format map()

 

11 index

12 isalnum(self)

13 isalpha

14 isdecimal

15 isdigit

16 isidentifier

17 islower

18 isnumeric

19 isprintable

20 isspace

21 istitle

22 isupper

23 join(self,iterable)

     li=['s','a','e','l','u','n','j','u','n']

     result=.join(li)

     result='_'.join(li)

24 rjust    置右

     ljust     置左

     center   置中

25  lower

26 lsrtip      清除左边空格

     rstrip

27  maketrans ()       建立两个字符串的对应关系

 

28 partition(self,sep)          利用sep进行分割字符串

29 replace(self,old,new,count=None)         用new 替换old   

30  rfind (self,sub,start=   ,  end=    )

      lfind

31  rindex

      lindex

32 rpartition(self,sep)

     lpartition(self,sep)

33

转载于:https://www.cnblogs.com/lj0303076/p/7435175.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值