def clearTxt(line):
if line != '':
line = line.strip()
intab = ""
outtab = ""
trantab = str.maketrans(intab, outtab)
#trantab = json.dumps(trantab).encode('utf-8')
pun_num = string.punctuation + string.digits
#pun_num = json.dumps(pun_num).encode('utf-8')
line = line.encode('utf-8')
#line = json.dumps(line).encode('utf-8')
line = line.translate(trantab,pun_num)
line = line.decode("utf-8")
location:line = line.translate(trantab,pun_num)。在我看来,它与“trantab”或“pun_num”的类型有关。“#”是我尝试过的。它们不起作用。所以。 .. 先感谢您