Python Dictionary type() Method

Python 字典Python Dictionary


Description

The Python dictionary type() function returns the type of the input variable. If the variable is a dictionary, it returns the dictionary type.

Syntax

type() method syntax:

type(dict)

Parameters

  • dict -- Dictionary.

Return Value

Returns the type of the input variable.

Example

The following example demonstrates how to use the type() function:

Example

#!/usr/bin/python

tinydict = {'Name': 'Zara', 'Age': 7};
print "Variable Type : %s" %  type (tinydict)

The output of the above example is:

Variable Type : <type 'dict'>

Python 字典Python Dictionary

Other Extensions