Python基础——列表、元组、字典
来源:互联网 发布:二战苏联远东部队知乎 编辑:程序博客网 时间:2024/06/13 03:09
!/usr/bin/python
-- coding: UTF-8 --
this is about lists
list1 =[‘python’,’java’,’android’,’sql’] #define a lists
list2 =[‘python’,’java’,’android’,’sql’] #define another lists
print list1[0]
a= cmp(list1,list2)
print a
list1.insert(1,’c++’) #insert a new list in the lists
print list1
list1.append(‘c’) #insert a new list in the last of the lists
print list1
list1.reverse() #reverse the lists
print list1
list1.extend(list2) #extend a new lists into the list
print list1
this is about tup
tup1 = (‘pychsics’,’chemistry’,1997,2000) #define the frist tup
tup2 =(1,2,3,4,5) #define the twice tup
print “tup1[0]:”,tup1[0] #printout the tup1[0]
print “tup2[1:5]:”,tup2[0:4] #print out the tup2[1-5]
tup3 =tup1+tup2
print tup3 #you can connect the tup1 and tup2 but you can’t alter them
del tup1 #delete tup1
print tup2*3
print 3 in tup2 #output a boolen if number in the tup or not
for x in tup2:
print x
this is about dictionary
dict1 = {‘name’:’qianbingbing’,’age’:24,’tel’:12343554}
print dict1[‘name’]
print dict1[‘age’]
print dict1[‘tel’]
del dict1[‘name’]
print dict1
dict1.clear()
print dict1
del dict1
dict2 = {‘name’:’qianbingbing’,’age’:24,’tel’:12343554}
print len(dict2)
- Python基础——列表、元组、字典
- Python基础(二)——字符串、列表、元组、字典
- Python基础(4)——字符串、列表、元组、字典
- Python基础 6 ---- Python 元组+列表+字典+文件
- 列表、字典、元组、文件——Python
- Python:元组、列表、字典
- python字典,列表,元组
- python 元组,列表,字典
- python 字典,列表,元组
- python 列表/元组/字典
- python--列表 、元组、字典
- python 列表、元组、字典
- python 列表,元组,字典
- Python 列表 元组 字典
- python列表元组字典
- Python基础之列表、元组、字典、集合的使用
- Python基础:列表,元组,字典,集合相关基本操作
- python基础3:字符串、列表、元组、字典
- iOS开发百度导航SDK的使用入门
- 文件的读和写(基础用法)
- Oracle 单个表查询速度极慢处理过程
- 编程学习第六天,参数传递
- centos6安装tomcat7
- Python基础——列表、元组、字典
- memset函数与二维数组初始化的问题
- 2015 Xcode7 真机调试(开发者)以及P12配置
- android:transcriptMode="normal" listview 设置这个属性 讲会滚动到最底一项
- 24 point game(ACM)
- QML的 property 支持的类型
- Spring Integration入门
- 快排中的partition函数
- xib简单使用.做个笔记,省的以后会忘掉......