zoukankan      html  css  js  c++  java
  • Python测试开发之---list、str、dict、tuple小结

    • 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() 返回元祖中某值首次出现的位置

  • 相关阅读:
    git
    redis
    Hexo-butterfly-magicv3.0.1(持续更新中....)
    转发好文章1
    0x07 Nagios Notifications
    0x06 nagios监控状态
    0x05 Nagios Host Check
    0x03 Nagios Plugins介绍
    0x02 Nagios CGI的认证和授权
    0x01 Nagios配置文件
  • 原文地址:https://www.cnblogs.com/bettywang/p/7922721.html
Copyright © 2011-2022 走看看