这是我的代码。不仅在此代码中,在我导入任何模块的每个代码中,ImportError: cannot import name 'package name' 都会出现
from string import maketrans
str = "geeksforgeeks"
str1 = "gfo"
str2 = "abc"
# using maktrans() to map elements of str2 with str1
mapped = maketrans(str1, str2);
# using translate() to translate using the mapping
print"The string after translation using mapped elements is : "
printstr.translate(mapped);
最佳答案
最后一行应该是
print str.translate(mapped)
不是
printstr.translate(mapped);
您能否在终端中运行此命令并发布输出
which -a python
关于json - 导入错误 : cannot import name 'maketrans' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52567910/