Given a statement type(type) – we have to print its return type value.
给定一个语句类型(类型) –我们必须打印其返回类型值。
Python type()函数 (Python type() function)
type() function is a library function in Python, it is used to get the type of the value/data type. It accepts an argument returns the class of the argument the object belongs to.
type()函数是Python中的一个库函数,用于获取值/数据类型的类型。 它接受参数返回对象所属参数的类。
Syntax:
句法:
type(value/variable/type)
Return value of type(type):
类型(类型)的返回值:
type is also a class of type, the statement type(type)) returns "type".
type也是type的类,语句type(type))返回“ type” 。
Return value of type(type(int)):
类型的返回值(类型(整数)):
type(int) returns <class 'str'> and the statement type(<class 'str'>) returns "type".
type(int)返回<class'str'> ,语句type(<class'str'>)返回“ type” 。
Python code to demonstrate example of type() function
Python代码演示type()函数的示例
# python code to demonstrate example of
# type() function
# printing types of various types of values
print(type('Hello'))
print(type(10))
print(type(10.23))
print(type(type))
print(type(type(int)))
print(type(type(str)))
print(type(type(10)))
print(type(type('Hello')))
Output
输出量
<class 'str'>
<class 'int'>
<class 'float'>
<class 'type'>
<class 'type'>
<class 'type'>
<class 'type'>
<class 'type'>
翻译自: https://www.includehelp.com/python/return-value-of-type-type-in-python.aspx