文件:

代码:

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. luogu 2982 [USACO10FEB]慢下来Slowing down dfs序+树状数组

    将要查询的信息放到 dfs 序上并用树状数组查一个前缀和即可. #include <bits/stdc++.h> #define N 100004 #define setIO(s) fre ...

  2. 【Android】查看内存

      [文章来源]http://blog.csdn.net/hudashi/article/details/7050897 查看内存使用的方式有很多种,但是各个方式查看到的结果可能会有微略不同. 方式一 ...

  3. 配置魔药(DP)

    配置魔药 [问题描述] 在<Harry Potter and the Chamber of Secrets>中,Ron的魔杖因为坐他老爸的Flying Car撞到了打人柳,不幸被打断了,从 ...

  4. asmlinkage的用法

    转自:https://www.cnblogs.com/china_blue/archive/2010/01/15/1648523.html https://blog.csdn.net/liujiaoy ...

  5. python定时任务-sched模块

    通过sched模块可以实现通过自定义时间,自定义函数,自定义优先级来执行函数. schedule = sched.scheduler( time.time,time.sleep) schedule是一 ...

  6. Python之python简介

    一.Python的优缺点 优点: 1.Python的定位是“优雅”.“明确”.“简单”,所以Python程序看上去总是简单易懂,初学者学Python,不但入门容易,而且将来深入下去,可以编写那些非常非 ...

  7. 服务器多进程powershell导致服务器瘫痪问题解决

    1.公司服务器多次无法访问,经查多由于开启了多个powershell进程,网上查询是被挖矿了,可通过将powershell应用程序重命名解决. 2.然而重命名的时候发现需要trustedInstall ...

  8. 2018-2019-2 20175227张雪莹《Java程序设计》实验四 《Android程序设计》

    2018-2019-2 20175227张雪莹<Java程序设计> 实验四 <Android程序设计> 实验报告封面 课程:Java程序设计 班级:1752班 姓名:张雪莹 学 ...

  9. L1-049 天梯赛座位分配 (20 分)

    L1-049 天梯赛座位分配 (20 分)(Java解法) 天梯赛每年有大量参赛队员,要保证同一所学校的所有队员都不能相邻,分配座位就成为一件比较麻烦的事情.为此我们制定如下策略:假设某赛场有 N 所 ...

  10. 深度解析 Qt 中动态链接库

    本文介绍的是Qt 中动态链接库,现在有些软件有自动升级功能,有些就是下载新的DLL文件,替换原来的动态链接库,MFC好象也有类似机制,Qt还有一种方式,就是把一个QWidget子类,编译成动态链接库. ...