1name = str('Zhu Shan Wei')2name1 =name.casefold()3print(name1) 填充字符串,第一个参数为填充后字符串宽度,第二个参数为填充的内容,默认为空格,利用center()、ljust()、rjust()方法,原字符串分别为居中、居左、居右,剩余填充;zfill()方法,参数为字符串的宽度,原字符串小于参数设定,则在左边补0 1...
'__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find...
语法 casefold()方法语法:str.casefold() lower()方法语法:str.lower() 参数:两者均无。 返回值:两者均返回将字符串中所有大写字符转换为小写后生成的字符串。 实例 #coding:utf-8str='# Hello WORLD;我爱你中国'if__name__=='__main__':print(str.casefold())#hello world;我爱你中国print(str.lower...
如果我们想要使用dir()函数列出一个模块或类的属性和方法,我们可以将该模块或类作为参数传递给dir()函数。例如,对于Python内置的os模块,我们可以使用以下代码列出它的所有属性和方法: >>> import os >>> dir(os) ['DirEntry', 'F_OK', 'MutableMapping', 'O_APPEND', 'O_BINARY', 'O_CREAT', 'O_DIR...
前言python中字符串对象提供了很多方法来操作字符串,功能相当丰富. print(dir(str)) [...'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isdecimal', 'isdigit', 'isidentifier', 'i 下面...
iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold...
由于Python 源代码也是一个文本文件,所以,当你的源代码中包含中文的时候,在保存源代码时,就需要务必指定保存为 UTF-8 编码。当 Python 解释器读取源代码时,为了让它按 UTF-8 编码读取,我们通常在文件开头写上这两行:
'__ne__','__new__','__reduce__','__reduce_ex__','__repr__','__rmod__','__rmul__','__setattr__','__sizeof__','__str__','__subclasshook__','capitalize','casefold','center','count','encode','endswith','expandtabs','find','format','format_map','index','...
'__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold', 'center', 'count',
iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold...