码迷,mamicode.com
首页 > 编程语言 > 详细

005 python语法_002

时间:2018-10-01 22:36:50      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:pytho   end   基本   strstr   list   pre   utf-8   style   pop   

 

技术分享图片

 

/*
时间: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

标签:pytho   end   基本   strstr   list   pre   utf-8   style   pop   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!