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

时间:2022-09-07 20:42:40

文件:

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

代码:

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模块时读错

解决:

修改文件名字

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

结果:

============= 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&colon; &&num;39&semi;module&&num;39&semi; object is not callable 原因分析

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

  2. python 报错——Python TypeError&colon; &&num;39&semi;module&&num;39&semi; object is not callable 原因分析

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

  3. python import 错误 TypeError&colon; &&num;39&semi;module&&num;39&semi; object is not callable

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

  4. TypeError&colon; &&num;39&semi;module&&num;39&semi; object is not callable cp fromhttp&colon;&sol;&sol;blog&period;csdn&period;net&sol;huang9012&sol;article&sol;details&sol;17417133

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

  5. PyCharm&plus;selenium环境搭建报错:Traceback &lpar;most recent call last&rpar;&colon; TypeError&colon; &&num;39&semi;module&&num;39&semi; object is not callable

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

  6. TypeError&colon; &&num;39&semi;module&&num;39&semi; object is not callable 原因分析

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

  7. pip安装pillow——死循环:&lbrack;WinError5&rsqb; &amp&semi; &lbrack;TypeError&colon;&&num;39&semi;module&&num;39&semi; object is not callable&rsqb;

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

  8. pip install 报错 TypeError&colon; &&num;39&semi;module&&num;39&semi; object is not callable

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

  9. Python&colon; TypeError&colon; &&num;39&semi;dict&&num;39&semi; object is not callable

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

随机推荐

  1. ubuntu git 使用

    apt-get install git//ubuntu安装git mkdir -p /var/www/gitProj //创建文件夹 cd /var/www/gitProj //进入文件夹 git i ...

  2. C&num;中Monitor和Lock以及区别

    Monitor对象 1.Monitor.Enter(object)方法是获取锁,Monitor.Exit(object)方法是释放锁,这就是Monitor最常用的两个方法,当然在使用过程中为了避免获取 ...

  3. gridview&plus;checkbox的各种操作【转】

    来源:http://hi.baidu.com/heavensxq/item/29736dcfbdc30403c710b2b1 1.首先如何在gridview中加入一个checkbox,注意不是chec ...

  4. 用Systemtap探索MySQL

    http://www.actionsky.com/docs/archives/168#Systemtap 目录 1 Systemtap 2 Systemtap 观测点的支持程度 2.1 官方编译的My ...

  5. css3渐变、背景、倒影、变形

    一.背景切割background-clip 语法:background-clip:border-box | padding-box | content-box: border-box      超出b ...

  6. bootstrap使用汇总

    //大多数功能都能够指定data属性来指定 但是,有必要的情况下使用jquery由于事件是不同的过程 //活动通常有两种状态show shown 通用和过去的 <!DOCTYPE html&gt ...

  7. MyBatisNet 学习

    SQL Maps Sql Maps是这个框架中最激动人心的部分,它是整个iBATIS Database Layer的核心价值所在.通过使用Sql Maps你可以显著的节约数据库操作的代码量.SQL M ...

  8. vhost-user 简介

    什么是 vhost-user 在 vhost 的方案中,由于 vhost 实现在内核中,guest 与 vhost 的通信,相较于原生的 virtio 方式性能上有了一定程度的提升,从 guest 到 ...

  9. &period;NET Core开源快速开发框架Colder发布 &lpar;NET Core2&period;1&plus;AdminLTE版&rpar;

    引言 上星期发布的.NET452+AdminLTE版框架得到了大家的大力支持,目前GitHub已获近100星,鄙人十分高兴能够帮助大家.其中有不少关心.NET Core的支持情况,因为未来的.NET平 ...

  10. Custom Default Node Colors and Shapes in Houdini 16&period;5

    A:before H16.5: 1.Create a file, named OPcustomize 2.Edit it like this: //Custom Default Shapes opde ...