首页 > 编程语言 > 详细

005 python语法_002

时间:2018-10-01 22:29:15      阅读:146      评论:0      收藏:0      [点我收藏+]

 

技术分享图片

 

/*
时间:2018/10/01
目录: 
  一: list
          1 基本用法
  二: 字典 
          1 整型
          2 浮点型
  三: 集合 
*/ 

 

一: list
  1 基本用法

# coding:utf-8

list = []
print(list)
print(type(list))

nInt = 12
fFloat = 12.12
bTrue = True
bFalse = False
strString = "12.12"

# 尾部插入
list.append(nInt)
list.append(fFloat)
list.append(True)
list.append(False)
list.append(strString)
print(list)

# 指定插入
list.insert(1, "insert")    # 插入位置 - 索引为1
print(list)

# 删除尾部
list.pop()
print(list)

# 指定删除
list.pop(2)     # 删除位置 - 索引为1
print(list)

# 指定删除
del list[0]     # 删除位置 - 索引为0
print(list)

# 数据修改
list[0] = 22
print(list)

 

[]
<class list>
[12, 12.12, True, False, 12.12]
[12, insert, 12.12, True, False, 12.12]
[12, insert, 12.12, True, False]
[12, insert, True, False]
[insert, True, False]
[22, True, False]

 

二: 字典
  1 
三: 集合

 

005 python语法_002

原文:https://www.cnblogs.com/huafan/p/9735916.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!