|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 lixiaoshuai 于 2015-3-4 05:29 编辑
看小甲鱼视频总结的
欢迎大家交流学习,帖子会不定期改进^ ^
----------------------------------------------------------------------------------------------分水岭
temp(1) type(temp) 显示<class 'int'> temp(1,2) 显示tuple temp()为空tuple
temp(ab,cd,ef) temp = temp[:1] + (2,) + temp[1:] 显示(ab,2,cd,ef)
str1 = 'i a\tm' str1 = str1[:1] + '7' + str[1:] str1 = 'i7a\tm'
str1.capitalize() 显示I7at\m 第一个字母变大写 str1还是'i7a\tm'
打开IDLE,按F1 英语版基本语法的学习
str1.casefold() 返回全为小写的字符串 str1还是'i7a\tm'
str1.center(5) 显示' i7a\tm ' 居中
str1.count('a') 显示1 计数
str1.endwith('xi') 显示False 判断结尾是否' '
str1.expandtabs() 显示'i7a m' 制表符 \t往前置位 默认为8
str1.find('a\') 显示2 返回索引所在位置
str1.index('a\') 显示2 找不到会返回异常
str1.isalnum() 显示false 字母或字符返回Ture(必须有字符)
str1.isalpha() 显示false 全是字符返回Ture(必须有字符)
str1.isnumeric() 显示false 全是数字字符返回Ture
str1.isdecimal() 显示false 全是十进制数返回Ture
str1.isdigit() 显示false 全是数字返回Ture
str1.islower() 显示false 全是小写字母返回Ture
str1.isspace() 显示false 全是空格返回Ture
str1.istitle() 显示false 单词首写全是大写
str1.isupper() 显示false 字符全是大写
str1.join('12') 显示'1i7a\tm2' str1作为分隔符
str1.ljust(7) 显示'i7a\tm ' 左对齐,填充7位
str1.lower() 显示'i7a\tm' 全大写变小写
str1.lstrip() 显示'i7a\tm' 去掉字符左边空格
str1.partition('a') 显示('i7','a','\tm') 隔开变元组
str1.replace(old,new[,count])
str1.rfind(sub[,start[,end]]) 从右查找
str1.rjust(width) 右对齐
str1.srpartition(sub) 右查找
str1.rstrip() 删除字符右边空格
str1.split(sep=None,maxsplit=-1) 切割为列表,默认以‘空格’为刀
str1.splitlines([keepends]) 按'\n'分行,返回keepends行
str1.startswith(perfix[,start[,end]]) endswith同样
str1.strip([chars]) 删左右字符
str1.swapcase() 大写变小写 小写变大写
str1.title 返回以大写开头的单词(单词中其他为小写)
str1.translate(table)
str1.tannslate(str.maketrans('a','b')) 字符中a,b互换
str1.upper() 全小写变大写
str1.zfill(width) 返回width位,字符串右对齐,前边0填充
|
评分
-
查看全部评分
|