Python测试开发之---liststrdicttuple小结

Posted Python测试开发

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python测试开发之---liststrdicttuple小结相关的知识,希望对你有一定的参考价值。

 

  • str的常用方法有:

str.digits 0-9的表示
str.uppercase 大写字母
str.lowercase 小写字母
str.letters 所有字母
" ".join(str) “”内必须有值,才可以用join
str.encode()
str.replace(x,y) 将str中的x替换为y
str.split() split中的值必须是str中含有的,否则起不到分割的效果
str.zfill(x),x为int类型,如果字符串的长度不足x位,则在前边用0填充

  • list的常用方法:

list.append()
list.insert(x,y)
del list[index]
pop list
"".join(list)
list.index(value) 输入list中的值,来查看它的下标
list.count(value) 计算list中value出现的次数

  • dict的常用方法:

dict[key]=value
del dict[key]
dict.items() return list [(key,value),...]
dict.keys() return list [key1,key2...]
dict.has_key() True or false
dict.values() return list [value1,value2...]
dict.update()
dict.clear clear all

  • tuple的常用方法:

tuple.count() 计算元祖中某个值出现的次数
tuple.index() 返回元祖中某值首次出现的位置























以上是关于Python测试开发之---liststrdicttuple小结的主要内容,如果未能解决你的问题,请参考以下文章

测试开发系列之Python开发mock接口

Python测试开发之---liststrdicttuple小结

测试开发系列之Python开发mock接口

测试开发系列之Python开发mock接口

python测试开发之_字符串练习

Python测试开发之函数