今天尝试使用pprint进行输出,语句为

>>>import pprint

>>>pprint(people)

结果报错,TypeError: 'module' object is not callable

{

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

}

原因分析:
Python导入模块的方法有两种:

import module 和 from module import

区别是前者所有导入的东西使用时需加上模块名的限定,而后者则不需要

例:

>>>import pprint

>>>pprint(people)

OR

>>>from pprint import *

>>>pprint(people)

Python TypeError: 'module' object is not callable 原因分析的更多相关文章

  1. python 报错——Python TypeError: 'module' object is not callable 原因分析

    原因分析:Python导入模块的方法有两种: import module 和 from module import 区别是前者所有导入的东西使用时需加上模块名的限定,而后者则不需要 例: >&g ...

  2. TypeError: 'module' object is not callable 原因分析

    程序代码 class Person: #constructor def __init__(self,name,sex): self.Name = name self.Sex = sex def ToS ...

  3. python -- TypeError: 'module' object is not callable

    文件: 代码: import pprintmessge = 'It was a bringht cold day in April,and the clocks were striking thrir ...

  4. TypeError: 'module' object is not callable cp fromhttp://blog.csdn.net/huang9012/article/details/17417133

    程序代码  class Person:      #constructor      def __init__(self,name,sex):           self.Name = name   ...

  5. python import 错误 TypeError: 'module' object is not callable

    python import 错误 TypeError: 'module' object is not callable 在这里,有 Person.py test.py; 在 test.py 里面 im ...

  6. PyCharm+selenium环境搭建报错:Traceback (most recent call last): TypeError: 'module' object is not callable

    环境搭建好后,代码如下: from selenium import webdriverdriver = webdriver.chrome()driver.get("http://www.ba ...

  7. Python: TypeError: 'dict' object is not callable

    问题:  TypeError: 'dict' object is not callable 原因:  dict()是python的一个内建函数,如果将dict自定义为一个python字典,在之后想调用 ...

  8. pip安装pillow——死循环:[WinError5] & [TypeError:'module' object is not callable]

    1.这次本来要安装个pillow,记得以前装了的,怎么这次就不行了.然后,下意识的使用:pip3 install pillow. 发现报错: [TypeError:'module' object is ...

  9. pip install 报错 TypeError: 'module' object is not callable

    $ pip install filetype Traceback (most recent call last): File "/usr/local/bin/pip2", line ...

随机推荐

  1. CS通用项目系统搭建——三层架构第一天

    CS通用项目:使用三层架构进行搭建 三层架构: 表现层(UI(User Interface)):展示给用户的层面,包含窗体控件数据等信息. 业务逻辑层(BLL(Business Logic Layer ...

  2. cpu资源长期使用率过高导致系统内核锁问题

    服务器跑大量高负载程序,会造成cpu soft lockup. 解决办法: #追加到配置文件中 echo 30 > /proc/sys/kernel/watchdog_thresh #查看 [r ...

  3. 编写一个 rpc

    手动编写一个 RPC 调用 package com.alibaba.study.rpc.framework; import java.io.ObjectInputStream; import java ...

  4. hibernate多生成一个外键以及映射文件中含有<list-index>标签

    (原文地址: http://blog.csdn.net/xiaoxian8023/article/details/15380529) 一.Inverse是hibernate双向关系中的基本概念.inv ...

  5. Ubuntu iso下载地址(14、16、18)

    Ubuntu镜像,快速下载 ubuntu 14.04: http://mirrors.aliyun.com/ubuntu-releases/14.04/ubuntu 16.04: http://mir ...

  6. HDU - 1695 GDU

    莫比乌斯反演基础. 用rep 去掉重复的对数,rep一定是奇数( 因为有(1,1 ) ) #include <bits/stdc++.h> using namespace std; #de ...

  7. [BZOJ2252]矩阵距离(BFS)

    题意 输入矩阵m行n列(m<=500,n<=500),只含0.1,输出离每个元素距离最近的1的距离,其中距离定义为D(aij,akl)=abs(i-k)+abs(j-l). 示例: 输入: ...

  8. [leetcode]432. All O`one Data Structure全O(1)数据结构

    Implement a data structure supporting the following operations: Inc(Key) - Inserts a new key with va ...

  9. Microsoft SQL Server 错误:948

    版本655指的是SQL2008, 版本611指的是SQL2005, (还有一个版本539指的是SQL2000) 楼主的情况属于典型的从高版本降低至低版本使用的情景. 按微软的官方说法, 是不支持从高版 ...

  10. route的简单使用

    route [add|del] [-net|-host] target [netmask Nm] [gw Gw] [[dev] If] add : 添加一条路由规则del : 删除一条路由规则-net ...