我需要搜索一个字符串并检查它的名称中是否包含数字。如果是这样的话,我想什么都不能代替。我已经开始做类似的事情,但我没有找到解决我的问题的方法。
table = "table1"
if any(chr.isdigit() for chr in table) == True:
table = table.replace(chr, "_")
print(table)
# The output should be "table"
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?