【问题标题】:translating python 3.4 code into python 2.7将 python 3.4 代码翻译成 python 2.7
【发布时间】:2017-06-28 16:29:32
【问题描述】:

我在将这段代码翻译成 python 2.7 时遇到问题,我不断收到“AttributeError: type object 'str' has no attribute 'maketrans' 的错误,我想知道是否有人可以帮忙?该代码应该是凯撒密码,对我在另一部分未显示的代码中输入的单词进行加密

    #

【问题讨论】:

  • 你有 from string import maketrans 吗?
  • 我刚刚搜索了文档,在 2.7 中它是string的方法

标签: python python-2.7 python-3.4 translate


【解决方案1】:

尝试string.maketrans 而不是str.makestrans

【讨论】:

    猜你喜欢
    • 2013-11-25
    • 2018-09-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-10
    • 2015-04-08
    • 1970-01-01
    • 2017-11-04
    相关资源
    最近更新 更多