【发布时间】:2019-03-15 02:22:45
【问题描述】:
我正在学习 Python 3。
我的代码
numbers = [1, 2]
print( type( numbers[0] ))
输出
<class ‘int’>
如何只打印
‘int’
或
int
【问题讨论】:
标签: python
我正在学习 Python 3。
我的代码
numbers = [1, 2]
print( type( numbers[0] ))
输出
<class ‘int’>
如何只打印
‘int’
或
int
【问题讨论】:
标签: python
您可以使用类型中的__name__ 属性。
>>> type(5).__name__
'int'
或者不使用type built-in:
>>> (5).__class__.__name__
'int'
【讨论】: