python datatype

解释性语言,有类型的概念,没有类型的实体

所以,类型很重要

今天,我在这里练练python的类型

//test.py

print int("10", 8) #8 scale
print long("123ABCDEF", 16) #16 scale
print float("1.2345")
print complex(0.3, 7.67) #create complex
print str(1)
print repr(3.1415926)
str = 'Hello World!'
print eval("str") #return str object
s = [12, 23, 34]
v = tuple(s)
print v
sn = list(v)
print sn
vv = set(v)
print vv
vv.add(45)
print vv
k = (1, 2)
v = ('1.1', '2.2')
d = (k, v)

print dict(d)
print zip(k, v)
print dict(zip(k, v))
print dict(((1, 1.1),(2, 2.2)))
print dict(((1,2),))
vvv = frozenset(vv)
#vvv.add(56)
print vvv
print chr(56)
print unichr(1028)
print ord('o')
print hex(1234)
print oct(1234)

//结果

# python test.py

8
4893429231
1.2345
(0.3+7.67j)
1
3.1415926
Hello World!
(12, 23, 34)
[12, 23, 34]
set([34, 12, 23])
set([34, 12, 45, 23])
{1: 2, '1.1': '2.2'}
[(1, '1.1'), (2, '2.2')]
{1: '1.1', 2: '2.2'}
{1: 1.1, 2: 2.2}
{1: 2}
frozenset([34, 12, 45, 23])
8
Є
111
0x4d2
02322

Finally:

感觉还行,打算继续,尤其是这么多未来方向都选定了这个语言来进行啦!

原文地址:https://www.cnblogs.com/woodzcl/p/7771705.html