文件:

代码:

import pprint
messge = 'It was a bringht cold day in April,and the clocks were striking thrirteen'
count = {}
for char in messge:
count.setdefault(char,0)
count[char] = count[char]+1
pprint.pprint(count)

报错:

Traceback (most recent call last):
File "C:\Users\Desktop\python\pprint.py", line 1, in <module>
import pprint
File "C:\Users\Desktop\python\pprint.py", line 7, in <module>
pprint.pprint(count)
TypeError: 'module' object is not callable

原因:

代码文件命名为了pprint,导致解释器读入pprint模块时读错

解决:

修改文件名字

结果:

============= RESTART: C:\Users\Desktop\python\pprint1.py =============

{' ': 12,
',': 1,
'A': 1,
'I': 1,
'a': 4,
'b': 1,
'c': 3,
'd': 3,
'e': 5,
'g': 2,
'h': 3,
'i': 6,
'k': 2,
'l': 3,
'n': 5,
'o': 2,
'p': 1,
'r': 6,
's': 3,
't': 6,
'w': 2,
'y': 1}

总结:

命名不规范,debug泪两行!

python -- TypeError: 'module' object is not callable的更多相关文章

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

    今天尝试使用pprint进行输出,语句为 >>>import pprint >>>pprint(people) 结果报错,TypeError: 'module' o ...

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

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

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

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

  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. PyCharm+selenium环境搭建报错:Traceback (most recent call last): TypeError: 'module' object is not callable

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

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

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

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

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

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

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

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

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

随机推荐

  1. C++关键字——register

    register修饰符暗示编译程序相应的变量将被频繁地使用,如果可能的话,应将其保存在CPU的寄存器中,以加快其存储速度.例如下面的内存块拷贝代码, #ifdef NOSTRUCTASSIGN mem ...

  2. Difference Between static and default methods in interface

    I was learning through interfaces when I noticed that you can now define static and default methods ...

  3. SSM整合(自己收藏)

    https://github.com/crossoverJie/SSM/blob/master/README-ZH.md

  4. 对于join操作,MySQL它是咋做的?

    首先我们对于join操作,需要了解两个概念:驱动表和被驱动表.首先先给出两张表: CREATE TABLE `t2` ( `id` ) NOT NULL, `a` ) DEFAULT NULL, `b ...

  5. mysql授权指定ip远程登录

    use user //更新用户表: UPDATE `user` SET `Host` = '175.6.6.230' where `Host` = '175.6.6.230'; //授权用户表: GR ...

  6. 演示Java如何调用Mysql的过程和函数

    这里只演示Java如何调用Mysql的过程和函数 --------------------------------------------------------------------------- ...

  7. hibernate中session的管理方式

    package loaderman.c_session; import loaderman.b_second_cache.Dept; import loaderman.b_second_cache.E ...

  8. python 通过 实例方法 名字的字符串调用方法

    方式1 - 反射 hasattr 方法 判断当前实例中是否有着字符串能映射到的属性或者方法, 一般会在  getattr 之前作为判断防止报错 getattr 方法 获取到当前实例中传入字符串映射到的 ...

  9. #dokcer部署code-server web版vscode+golang

    codercom/code-server:latest不支持插件在线安装 codercom/code-server:v2目前为最新版1. #创建 docker rm -f vscode docker ...

  10. jenkins常用插件安装

    1.常用jenkins插件 插件相关下载地址:http://updates.jenkins-ci.org/download/plugins/ git.hpi git-client.hpi gitlab ...