Python基本数据类型——字符串
字符串是字符的序列表示,可以由一对单引号(’),双引号(“)或三引号(’’’)构成。
其中单引号和双引号都可以表示单行字符串,两者作用相同。使用单引号时,双引号可以作为字符串的一部分,反之亦然。
三引号可以表示单行或多行字符串。
1、字符串实质上是字符的序列表示
2、按住鼠标左键再单击str可进入源码查看str拥有的函数方法按住鼠标左键再单击str可进入源码查看str拥有的函数方法
3、例如,查看到isalpha()方法的源码如下:
def isalpha(self, *args, **kwargs): # real signature unknown
"""
Return True if the string is an alphabetic string, False otherwise.
A string is alphabetic if all characters in the string are alphabetic and there
is at least one character in the string.
"""
pass
- isalph()方法使用实例:
s1 = 'python'
s2 = '223'
print(s1.isalpha(