Python笔记:1.2.5数字与表达式_类型转换

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/bq_cui/article/details/89885973
# -*- coding: utf-8 -*-
"""
Created on Mon May  6 16:29:13 2019

@author: Administrator
"""

print(int(989))
print(float(989))
print(complex(989))
print(repr(989))
print(eval('2000+18'))
print(chr(100))
print(ord('d'))
print(hex(989))
print(oct(989))


s='game over 2019'
print(tuple(s))
print(list(s))
print(set(s))
print(frozenset(s))

运行:

989
989.0
(989+0j)
989
2018
d
100
0x3dd
0o1735
('g', 'a', 'm', 'e', ' ', 'o', 'v', 'e', 'r', ' ', '2', '0', '1', '9')
['g', 'a', 'm', 'e', ' ', 'o', 'v', 'e', 'r', ' ', '2', '0', '1', '9']
{'g', 'r', '0', '1', '2', 'e', ' ', 'a', 'm', 'o', 'v', '9'}
frozenset({'g', 'r', '0', '1', '2', 'e', ' ', 'a', 'm', 'o', 'v', '9'})

猜你喜欢

转载自blog.csdn.net/bq_cui/article/details/89885973