python Data type conversation

时间:2023-03-08 16:16:07
>>> repr(111.5)
'111.5'
>>> repr(10)
''
>>> int("")
11
>>> long("")
22L
>>> float("1.22")
1.22
>>> hex(19)
'0x13'
>>> oct(20)
''
>>> tuple("1,2,3,4,5")
('', ',', '', ',', '', ',', '', ',', '')
>>> tuple("")
('', '', '', '', '')
>>> tuple([1,2,3,4,5])
(1, 2, 3, 4, 5)
>>> tuple({1:2,3:4})
(1, 3)
>>> list((1,2,3,4,5))
[1, 2, 3, 4, 5]
>>> list("")
['', '', '', '', '']
>>> list({1:2,3:4})
[1, 3]
>>>
>>> chr(65)
'A'
>>> ord("A")
65
#list to str
>>> "".join(["a",""])
'a1'