# -*- coding: gb2312 -*- """ Created on Fri Sep 25 23:13:57 2015 @author: Administrator """ """1、第一个程序""" """1:输出 print "hello","world" """ """2:输入 a = raw_input() print "This input is",a """ """2、认识数字""" """3:数值类型转换 print "整数相除得整数",1/2 print "小数除整数得小数",1./2 print "小数除整数得小数",float(1)/2 print "小数相除得小数",1.5/0.7 print "小数相除得整",int(1.5/0.7) print "小数相除得整",1.5//0.7 print "2的3次方",2**3 print "取余运算",8%6 """ """3、认识字符串 """ """print "转义:hello "world" """ """print "转义:hello"world" print "拼接:hello"+" world" print "乘号作用" + "123"*3 print "字符串长度",len("hello") print "数字转字符串"+str(123)+"123" print "字符串转数字",int("123") + 123 """ """4、字符串的索引和切片 print "索引:abcdef的第一个字符","abcdef"[0] print "索引:abcdef的最后一个字符","abcdef"[-1] print "切片: abcdef截取部分","abcdef"[1:3] print "切片: abcdef截取开头","abcdef"[:3] print "切片: abcdef截取结尾","abcdef"[3:] print "切片: abcdef截取全部","abcdef"[:] print "切片: abcdef补充","abcdef"[::1] print "切片: abcdef补充:跳2个字符","abcdef"[::2] print "切片: abcdef补充:从后向前跳2个字符","abcdef"[::-2] """ """5、聚沙成塔之list a=[0,1,2,3,4,5,[6,7,8]]; print "list下标",a[0] print "list下标",a[-1] print "list下标",a[-1][1] b=[1,2,3] c=[4,5,6] print "list拼接",b+c print "list b*3",b*3 print "list长度 len()",len(b) del a[0] print "list 删除 del a[0]",a a.insert(1,1.5) print "list插入insert",a b.append(7) b.append(8) print "list尾部插入",b """ """6、不可变的list 元组 a=(1,2,3) a[0] = 5 """ """7、可以自定义索引的list dict contact = {"LiLei":"0123456","HanMeiMei":"234569"} print contact print "检索",contact["LiLei"] contact["zhangsan"]="231411" print "添加",contact contact["LiLei"] = "6543210" print "修改",contact del contact["LiLei"] print "删除",contact """