Given a valid (IPv4) IP address, return a defanged version of that IP address.
A defanged IP address replaces every period "."with "[.]".
class Solution: def defangIPaddr(self, address: str) -> str: return address.replace('.','[.]')
是 every 哦,我记得 js 的 replace 只会替换第一个,要用到正则吧?
python 的都会替换的,你可以试一下,js 我不懂
https://www.jianshu.com/p/82886d77440c