
python字符串
文章平均质量分 60
九天小牛
这个作者很懒,什么都没留下…
展开
-
来不及解释!python字符串常用方法大全,先收藏再说
目录1.0 capitalize()函数2.0 title()函数3.0swapcase()函数4.0 lower()函数5.0upper()函数6.0 casefold()函数7.0 center()函数8.0ljust()函数9.0 rjust()函数10.0 zfill()函数11.0 count()函数12.0 encode()...原创 2018-10-12 21:19:12 · 32634 阅读 · 22 评论 -
python中capitalize()函数的用法
python字符串函数用法大全链接capitalize()函数描述:将字符串的第一个字母变成大写,其余字母变为小写。语法:str.capitalize() —> str 返回字符串程序示例:str1 = "i Love python"str2 = " i Love python" #字母i前有空格str3 = "I Love python"print(str1....原创 2018-10-12 21:57:37 · 21435 阅读 · 0 评论 -
python字符串isalnum()函数
python字符串函数用法大全链接isalnum()函数描述:检测字符串是否由字母和数字组成。语法:str.isalnum() -> bool 返回值为布尔类型(True,False)str中至少有一个字符且所有字符都是字母或数字则返回 True,否则返回 False程序示例:str1 = "i love python 666" #有空格,不全是字母或数字st...原创 2018-10-18 16:23:24 · 19171 阅读 · 3 评论 -
python中decode()函数函数的用法
python字符串函数用法大全链接decode()函数描述:以 encoding 指定的编码格式解码字符串,默认编码为字符串编码。 encoding ——要使用的编码,如:utf-8,gb2312,cp936,gbk等。 errors ——设置不同解码错误的处理方案。默认为 'strict',意为编码错误引起一个 UnicodeDecodeError。 其它可能得值有 'i...原创 2018-10-12 22:09:56 · 29142 阅读 · 0 评论 -
python中expandtabs()函数的用法
python字符串函数用法大全链接expandtabs()函数描述:返回一个字符串的副本。使原字符串中的制表符("\t")的使用空间变大。使用空格来扩展空间。语法: str.expandtabs(tabsize=8) —> str 返回字符串tabsize 的默认值为8。tabsize值为0到7等效于tabsize=8。tabsize每增加1,原字符串中“\t”的空间会多...原创 2018-10-13 20:47:35 · 4725 阅读 · 1 评论 -
python中startswith()函数的用法
python字符串函数用法大全链接startswith()函数描述:判断字符串是否以指定字符或子字符串开头。语法:str.endswith("suffix", start, end) 或str[start,end].endswith("suffix") 用于判断字符串中某段字符串是否以指定字符或子字符串结尾。—> bool 返回值为布尔类型(True,Fals...原创 2018-10-13 20:48:20 · 37226 阅读 · 3 评论 -
python中endswith()函数的用法
python字符串函数用法大全链接endswith()函数描述:判断字符串是否以指定字符或子字符串结尾。语法:str.endswith("suffix", start, end) 或str[start,end].endswith("suffix") 用于判断字符串中某段字符串是否以指定字符或子字符串结尾。—> bool 返回值为布尔类型(True,False)...原创 2018-10-13 20:48:00 · 66036 阅读 · 1 评论 -
python中encode()函数的用法
python字符串函数用法大全链接encode()函数描述:以指定的编码格式编码字符串,默认编码为 'utf-8'。语法:str.encode(encoding='utf-8', errors='strict') -> bytes (获得bytes类型对象)encoding 参数可选,即要使用的编码,默认编码为 'utf-8'。字符串编码常用类型有:utf-8,gb2...原创 2018-10-12 22:08:09 · 47041 阅读 · 4 评论 -
python中count()函数的用法
python字符串函数用法大全链接count()函数描述:统计字符串里某个字符出现的次数。可以选择字符串索引的起始位置和结束位置。 语法:str.count("char", start,end) 或 str.count("char") -> int 返回整数str —— 为要统计的字符(可以是单字符,也可以是多字符)。 star —— 为索...原创 2018-10-12 22:06:07 · 45930 阅读 · 2 评论 -
python中center()函数的用法
python字符串函数用法大全链接center()函数描述:返回一个长度为width,两边用fillchar(单字符)填充的字符串,即字符串str居中,两边用fillchar填充。若字符串的长度大于width,则直接返回字符串str语法:str.center(width , "fillchar") -> str 返回字符串 注意:引号不可省程序示例:st...原创 2018-10-12 22:04:13 · 45494 阅读 · 5 评论 -
python中casefold()函数的用法
python字符串函数用法大全链接casefold()函数描述:将字符串中的所有大写字母转换为小写字母。语法:str.casefold() -> str 返回字符串程序示例:str1 = "I Love Python"str2 = "Groß - α" #德语 大写αprint(str1.casefold())print(str1.lower())print...原创 2018-10-12 22:02:32 · 6516 阅读 · 0 评论 -
python中lower()函数的用法
python字符串函数用法大全链接lower()函数描述:将字符串中的所有大写字母转换为小写字母。语法:str.lower() -> str 返回字符串程序示例:str1 = "I Love Python"str2 = "Groß - α" #德语 大写αprint(str1.casefold())print(str1.lower())print(str2....原创 2018-10-12 22:00:36 · 79491 阅读 · 1 评论 -
python字符串split()函数
python字符串函数用法大全链接split()函数描述:拆分字符串。通过指定分隔符sep对字符串进行分割,并返回分割后的字符串列表语法: str.split(sep=None, maxsplit=-1) -> list of strings 返回 字符串列表 或str.split(sep=None, maxsplit=-1)[n] se...原创 2018-10-18 16:35:16 · 4057 阅读 · 0 评论