python基础

#coding=utf-8
print "你好,世界"

print 2**10

var =1
print var

##x=input("x:")
##y=input("y:")
##print x*y

print 12+int('1')
print str(12)+"1"

seq="0123456789"
print seq[0]
print seq[-1]
print seq[0:5]
print seq[5:]
print seq[-3:-1]
print seq[-3:]
print seq[:]
print seq[::2]
print seq[::-2]
print seq[9:1:-1]
print [1,2,3]+[4,5,6]
print [1,2,3]*2
print [None]*10
print 1 in [1,2]

data=[0,1,2,3,4,5,6,7,8,9]

data[0]="a"
print data

del data[0]
print data

data[6:]=[8,9,10]
print data

#字符串格式化
print "% 10s" % "------"

print {"title":"title","body":"body"}
print dict(title="title",body="body")

print 'a','b'
#三元运算符
print "10>1" if 10>1 else "unhappened"

for x in range(1,10):
    print x

for x in range(1,10,2):
    print x


for key in {"title":"title","body":"body"}:
    print key
#带索引的遍历

for index,x in enumerate(range(1,10)):
    print index,x
#zip 方法
##    for x,y in zip(range(1,10),range(1,10)):
##        print x,y
    if(11==11):
        pass
    exec('print(x)',{"x":"abc"})
    print (eval('x*2',{"x":5}))
    print range(len([4,2]))

 

posted @ 2015-01-12 15:29  有态度的80后  阅读(205)  评论(0编辑  收藏  举报