主页
Python
Python String translate() 方法
demo_ref_string_translate1
运行 ❯
×
更改方向
保存代码
更改主题
#use a dictionary with ascii codes to replace 83 (S) with 80 (P): mydict = {83: 80}; txt = "Hello Sam!"; print(txt.translate(mydict));
Hello Pam!