zoukankan      html  css  js  c++  java
  • 组合数据类型综合练习

    字符串

    str = "shanruansanban"
    for i in str:
        print(i)
    

    列表

    list = ['xuhuaipeng','sun','cheng']
    for i in list:
        print(i)
    

    元组

    tup = ('xuhuaipeng','sun','cheng');
    for i in tup:
        print(i)

    字典

    d = {'xu' : 222, 'sun' : 221,'chen' : 223 }
    g = d.items()
    for i in g:
        print(i)

    集合

    var = {'xuhuaipeng','sun','cheng'}
    for i in var:
      print(i)
    

      

    总结列表,元组,字典,集合的联系与区别

          列表是可变的对象,可进行动态的增加、删除、更新,即str.pop()和str.extend()等操作,用[]表示。

          元组和列表在结构上没有什么区别,唯一的差异在于元组是只读的,不能修改。元组用“()”表示。

          字典是存储键值对数据的对象,字典的元素都是无序的,且键不能相同,可以通过键,找到值,字典最外面用大括号,每一组用冒号连接起来。

          集合相当于字典的键,也是一个无序不重复的元素集,用一对{}表示。

  • 相关阅读:
    Meterpreter
    CHM木马
    浅析ARP协议及ARP攻击
    python绝技 — 使用PyGeoIP关联IP地址和物理位置
    python虚拟环境virtualenv的安装与使用
    python调用nmap探测局域网设备
    提权
    Nexpose
    docker安装使用
    一些渗透测试练习环境介绍
  • 原文地址:https://www.cnblogs.com/phoenlix/p/8626006.html
Copyright © 2011-2022 走看看