作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 petl 软件包,该软件包是我在 virtulaenv 中使用 pip 和 python 3.4 安装的。当我尝试测试 petl 包是否在 python shell 中正确安装时我这样做是为了检查
$ python
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from petl import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/.env/lib/python3.4/site-packages/petl/__init__.py", line 10, in <module>
from petl.util import header, fieldnames, data, records, rowcount, look, see, \
File "/home/user/.env/lib/python3.4/site-packages/petl/util.py", line 14, in <module>
from string import maketrans
ImportError: cannot import name 'maketrans'
>>>
我试图检查 maketrans 是否存在于我运行的字符串包中
>>> from string import maketrans
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'maketrans'
>>>
发现默认的python字符串包没有这个。我不确定为什么 petl 包使用了它而没有在其依赖项中提及它,以及如果它是默认的 python 包那么为什么它会给出导入错误。
不知道发生了什么,请有人帮忙
最佳答案
在Python2中,maketrans
是属于string
模块的函数。然而在Python3中,maketrans
是str
类型的静态方法。
关于python - Maketrans 不适用于 python3.4 的 petl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27539884/
我是一名优秀的程序员,十分优秀!