repr方法和float类型 数字e的使用

>>> s = 'RUNOOB'
>>> repr(s)
"'RUNOOB'"
>>> dict = {'runoob': 'runoob.com', 'google': 'google.com'};
>>> repr(dict)
"{'google': 'google.com', 'runoob': 'runoob.com'}"


s="物品\t单价\t数量\n包子\t1\t2"
print('01', s)
print('02', repr(s))
输出:
01 物品	单价	数量
包子	1	2
02 '物品\t单价\t数量\n包子\t1\t2'
import decimal
print('1e4 ', repr(1e4))
print('10e4', repr(10e3))
print(int(50e3))
print(int(10e3))
print(int(0b10))
print(int(0x1f))
print(1.24e3, type(1.24e3))
print(decimal.Decimal(10e3))

输出:

1e4  10000.0
10e4 10000.0
50000
10000
2
31
1240.0 <class 'float'>
10000
posted @ 2022-08-14 23:22  ty1539  阅读(39)  评论(0编辑  收藏  举报