mystring=input() newstring=mystring.replace("!","1").replace("@","2").replace("#","3").replace("$","4").replace("%","5").replace("^","6").replace("&","7").replace("*","8").replace("/","9").replace(".",0) print(newstring)
时间: 2023-07-03 17:28:57 浏览: 54
这段代码的作用是将输入的字符串中的特定字符替换成数字,并将新字符串输出。其中,"!"被替换成1,"@"被替换成2,"#"被替换成3,"$"被替换成4,"%"被替换成5,"^"被替换成6,"&"被替换成7,"*"被替换成8,"/"被替换成9,"."被替换成0。你可以输入任意字符串,程序将会将特定字符替换成对应的数字输出。
阅读全文