Skip to content Skip to sidebar Skip to footer

How Do I Keep Python From Printing Type Information?

(This question is somehow related to this one.) I have an object 'o', which is returned from a third-party module (whose code is quite intricate). When printing this object I get t

Solution 1:

It looks like the TYPES are verbose info that is not a part of the key's value. I would suggest use the build in type function .

data = {"hello": 1}
# print the type for the objectprint(type(data))

# to get for each key,valfor k,v in data.iteritems():
    print(type(k), type(v))

Output:

<type'dict'>
(<type'str'>, <type'int'>)

Post a Comment for "How Do I Keep Python From Printing Type Information?"