今天尝试使用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)