文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>python的数据类型

python的数据类型

时间:2007-09-14  来源:jcodeer

'''1.整型(integer)'''
nByte = 0xFF
print 'nByte(0xFF) = %d\n' % nByte

nShort = 0xFFFF
print 'nShort(0xFFFF) = %d' % nShort

nShort = -1
print "nShort(-1) = %x" % nShort

nInt = 2**31
print '2**32 = %d\n' % nInt
print '2**32 = %x\n' % nInt

nInt = 2**33
print '2**33 = %d\n' % nInt

nInt = 2**63
print '2**63 = %d' % nInt

nInt = 2**65
print '2**65 = %x\n' % nInt

'''2.浮点型(float)'''
pi = 3.1415926
print pi

#精度问题
pi = 3.1415192654856952
print "%.20f\n" % pi

'''3.复数类型complex'''
pos = 10 + 20j
print pos

pos = 10.01 + 20.02j
print pos

'''4.字符串(string)'''
str = 'jcodeer'
print '%s\n' % str

str = "jcodeer"
print '%s\n' % str

str = '''
j\
c\
o\
d\
e\
e\
r\
'''
print str

'''5.列表(list)'''
#iterator
lst = [2,4,6,8,10,12,14]
for it in lst:
    print it
#index
for i in range(len(lst)):
    print lst[i]
#consider a string as list
str_list = 'jcodeer'
for it in str_list:
    print it

'''6.字典(dictionary)'''
dict = {'8680':'[email protected]','8008':'[email protected]','8003':'[email protected]'}
for k,v in dict.iteritems():
    print k ,' = ', v

相关阅读 更多 +
排行榜 更多 +
找茬脑洞的世界安卓版

找茬脑洞的世界安卓版

休闲益智 下载
滑板英雄跑酷2手游

滑板英雄跑酷2手游

休闲益智 下载
披萨对对看下载

披萨对对看下载

休闲益智 下载