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模块时读错
解决:
修改文件名字
结果:
============= 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的更多相关文章
- Python TypeError: 'module' object is not callable 原因分析
今天尝试使用pprint进行输出,语句为 >>>import pprint >>>pprint(people) 结果报错,TypeError: 'module' o ...
- python 报错——Python TypeError: 'module' object is not callable 原因分析
原因分析:Python导入模块的方法有两种: import module 和 from module import 区别是前者所有导入的东西使用时需加上模块名的限定,而后者则不需要 例: >&g ...
- python import 错误 TypeError: 'module' object is not callable
python import 错误 TypeError: 'module' object is not callable 在这里,有 Person.py test.py; 在 test.py 里面 im ...
- 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 ...
- PyCharm+selenium环境搭建报错:Traceback (most recent call last): TypeError: 'module' object is not callable
环境搭建好后,代码如下: from selenium import webdriverdriver = webdriver.chrome()driver.get("http://www.ba ...
- TypeError: 'module' object is not callable 原因分析
程序代码 class Person: #constructor def __init__(self,name,sex): self.Name = name self.Sex = sex def ToS ...
- pip安装pillow——死循环:[WinError5] & [TypeError:'module' object is not callable]
1.这次本来要安装个pillow,记得以前装了的,怎么这次就不行了.然后,下意识的使用:pip3 install pillow. 发现报错: [TypeError:'module' object is ...
- pip install 报错 TypeError: 'module' object is not callable
$ pip install filetype Traceback (most recent call last): File "/usr/local/bin/pip2", line ...
- Python: TypeError: 'dict' object is not callable
问题: TypeError: 'dict' object is not callable 原因: dict()是python的一个内建函数,如果将dict自定义为一个python字典,在之后想调用 ...
随机推荐
- python中global的用法——再读python简明教程
今天看了知乎@萧井陌的编程入门指南,想重温一下 <python简明教程>,对global的用法一直不太熟练,在此熟练一下,并实践一下python中list.tuple.set作为参数的区别 ...
- google中select添加onclick
有下拉跳转框如下所示: <select name="page" size="1" > <option onclick="refurb ...
- 修改checkbox样式-1
说明 使用伪类来对复选框进行样式修改.以下以最简单的一个样式修改为实例进行说明. 步骤介绍: 将一个label与复选框进行绑定,将两者放在同一个div下 调整 label的外部样式使其作为复选框的外形 ...
- C++ #include<algorithm>
今天下午大致学完了进阶指南中algorithm头文件下的内容,在这里进行一个总结. reverse翻转 顾名思义,reverse进行的操作就是翻转原来的顺序,理解非常简单,故不赘述. 操作样例 ...
- 笔记一(固件、BIOS、UEFI)
1.固件 固件一般是指保存在ROM中的程序和数据,通过固件操作系统按照标准的设备驱动实现特定机器的运行. 简单来讲,固件就是固化在ROM的软件,当然也可以通过特定的工具进行升级. MP3.MP4.手机 ...
- 关于Date
1.java DateUtil工具包可将"Wed, 21 Dec 2022 14:20:00 GMT"格式的字符串专程Date类型: Date expiration = DateU ...
- Java 比较两个字符串的相似度算法(Levenshtein Distance)
转载自: https://blog.csdn.net/JavaReact/article/details/82144732 算法简介: Levenshtein Distance,又称编辑距离,指的是两 ...
- JS 省市联动 ajax
省市联动 //省市联动 $('.locationCode').change(function () { var val = $(this).val(); if ...
- 查一张表占多少空间Bytes
SELECT SUM(BYTES)/1024/1024||'MB' 占用空间 FROM dba_segments WHERE segment_name = '表名' AND owner = '用户名' ...
- React Native 日常报错
在学习React.js 或 React Native 过程中,有时看着别人的框架或代码,但总是会出现错误,因为React或之中用到的一些包经常更新,有些代码或教程就显得过旧了. 一.日常报错 'con ...