gpt4 book ai didi

python - Maketrans 不适用于 python3.4 的 petl

转载 作者:行者123 更新时间:2023-12-01 20:17:05 25 4
gpt4 key购买 nike

我正在使用 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中,maketransstr类型的静态方法。

关于python - Maketrans 不适用于 python3.4 的 petl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27539884/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com