Notes Python's string of commonly used functions

Dish ape Python learning journey

This is the first blog, really want to change themselves. Here record their bit to learn. I hope it will get better and better.

string commonly used functions

import string
#将字符串的第一个字母大写
string.capitalize()
#获得字符串中某一子字符串的数目
string.count()
#获得字符串中某一子串的起始位置,无则返回-1
string.find()
#检测字符串是仅包含0-9,A-Z,a-z
string.isalnum()
#检测字符串是仅包含A-Z,a-z
string.isalpha()
#检测字符串是仅包含数字
string.isdigit()
#检测字符串是否均为小写字母
string.islower()
#检测字符串所有字符是否均为空白字符
string.isspace()
#检测字符串中所有单词是否为首字母大写
string.istitle()
#检测字符串中是否均为大写字母
string.isupper()
#连接字符串
string.join()
#将字符串全部转换为小写
string.lower()
#分割字符串
string.split()
#将字符串中的大写字母转换为小写,小写字母转换为大写
string.swapcase()
#将字符串中的单词首字母大写
string.title()
#将字符串中的全部字母转换为大写
string.upper()
#获取字符串长度
len(string)
Released six original articles · won praise 1 · views 162

Guess you like

Origin blog.csdn.net/weixin_45761659/article/details/102596218