我曾尝试使用此函数在变量完成内创建输出,但似乎没有任何效果
punctuations = '''!()-[]{};:'"\,<>./?@#$%^&*_~ '''
def puncrem(x,y):
for char in str(x):
if char not in punctuations:
y = y + char
return y
start = "h%e*l(l&o"
finish = ""
puncrem(start,finish)
print(finish)
答案 0 :(得分:0)
你必须使用这样的返回值:
punctuations = '''!()-[]{};:'"\,<>./?@#$%^&*_~ '''
def puncrem(x):
y = ""
for char in str(x):
if char not in punctuations:
y = y + char
return y
start = "h%e*l(l&o"
finish = puncrem(start)
print(finish)