是否为字符或者数字: isalnum 是否为字母:isalpha 是否为数字:isdigit 是否为小写字母:islower 是否为空格:isspace 是否为标题:istitle 是否为大写字母:isupper 是否为十进制字符:isdecimal
例子:
第一个判断有空格,并不算是字符或者数字
第二个两个字符首字母都是大写,所以为标题
转换为小写字母:lower 转换为大写字母:upper 转换为标题:title 大小写反转:swapcase 首字母大写其余小写:capitalize
例子:
startswith 是否以指定字符串开头 endswith 是否以指定字符串结尾例子:判断开头
url = 'http://www.baidu.com'
if url.startswith('http'):
print(f"{url}是一个正确的网址")
例子:判断结尾
filename = 'hello.png'
if filename.endswith('.png'): #如果以什么结尾
print(f'{filename}是图片文件')
elif filename.endswith('.mp3'):
print(f'{filename}是音乐文件')



