我正在做一个任务,要求我更改下面的代码,以便第4行使用蓝藻str.isalnum而第5-7行变成只使用一行结构更换. 在
s = 'p55w-r@d'
result = ''
for c in s:
if(c not in 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'):
result += '*'
else:
result += c
print(result)
到目前为止,我得到的是:
^{pr2}$第二个代码的输出需要等于代码1的输出:
p55w*r*d
只需添加else部分即可完成:
在合理的情况下,最能满足任务要求的是:
我知道如何用两条线来做同样的事情:
输出:
^{pr2}$相关问题 更多 >
编程相关推荐