str.translate gives TypeError - Translate takes one argument (2 given), worked in Python 2

前端 未结 5 1977
春和景丽
春和景丽 2020-11-29 00:24

I have the following code

import nltk, os, json, csv, string, cPickle
from scipy.stats import scoreatpercentile

lmtzr = nltk.stem.wordnet.WordNetLemmatizer         


        
5条回答
  •  孤城傲影
    2020-11-29 01:25

    If you just want to implement something like this: "123hello.jpg".translate(None, 0123456789") then try this:

     "".join(c for c in "123hello.jpg" if c not in "0123456789")
    

    Ouput: hello.jpg

提交回复
热议问题