'''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
|