Python TypeError: 'module' object is not callable 緣由分析

今天嘗試使用pprint進行輸出,語句爲it

>>>import pprint import

>>>pprint(people)module

結果報錯,TypeError: 'module' object is not callableobject

{方法

bob = [['name','bob smith'],['age',42],['pay',30000],['job','software']]
sue = [['name','sue jones'],['age',42],['pay',40000],['job','hardware']]
people = [bob,sue]im

}call

緣由分析:
Python導入模塊的方法有兩種:ab

import module 和 from module import

區別是前者全部導入的東西使用時需加上模塊名的限定,然後者則不須要

 

例:

>>>import pprint

>>>pprint(people)

OR

>>>from pprint import *

>>>pprint(people)

相關文章
相關標籤/搜索