str0 = input("Enter str: ")
str0 = str0.replace(str0, '_')
print(str0)
我需要在不使用循环或条件的情况下替换每个字符
最佳答案
str0 = input("Enter str: ")
str0 = '_'*len(str0)
print(str0)
应该可以。乘法会放入正确数量的 _
,以便将它们全部替换。
关于python - 用特定的单字符python替换给定字符串的所有字符,不带循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49085712/