如果这是PHP,我可能会这样做:
function no_more_half_widths($string){
$foo = array('?','?','?','?','?','?','?','?','?','??')
$bar = array('1','2','3','4','5','6','7','8','9','10')
return str_replace($foo, $bar, $string)
}
Run Code Online (Sandbox Code Playgroud)
我在python中尝试过.translate函数,它表明数组的大小不同.我认为这是因为各个字符都是用utf-8编码的.有什么建议?