Python的基本数据类型(2)

字符串(str)的魔法方法

  def isalnum(self):

  def isalpha(self):

  def isdigit(self):

  def isidentifier(self):

  def isnumeric(self):

  def isprintable(self):

  def isspace(self):

  def istitle(self):

  def islower(self):判断字符串中的字符是否全部为小写,如果权威小写,则返回TRUE,否则返回FALSE,如果字符串中含有汉字也返回False。例如:

1 test = 'I am Charles, I am 26!'
2 v1 = test.islower()
3 print(v1)
4 
5 False
1 test = 'I am Charles, I am 26!'
2 test1 = test.lower()
3 v2 = test1.islower()
4 print(v2)
5 
6 True 

  def isupper(self);判断字符串中的字符是否全部为大写字母,如果是大写,返回TRUE,否则返回FALSE,如果含有中文,同样返回FALSE。例如:

1 test = '明天你好'
2 v1 = test.isupper()
3 print(v1)
4 
5 False
1 test = 'I am Charles, I am 26!'
2 v1 = test.isupper()
3 print(v1)
4 
5 False
1 test = 'I am Charles, I am 26!'
2 v1 = test.isupper()
3 test1 = test.upper()
4 v2 = test1.isupper()
5 print(v2)
6 
7 True

 

def join(self, iterable):
def ljust(self, width, fillchar=None):
def lstrip(self, chars=None):
def rstrip(self, chars=None):
def strip(self, chars=None):
def maketrans(self, *args, **kwargs):
def partition(self, sep): 
def rpartition(self, sep): 
def swapcase(self):






posted @ 2019-11-07 15:19  小南落  阅读(161)  评论(0)    收藏  举报