从一个字符串中减去另一个字符串,得到一个新的字符串结果
replace() 方法
host_ip = 'hello world'
host = 'world'
ip = host_ip.replace(host, "")
print(ip)
re.sub() 方法
import re
host_ip = 'hello world'
host = 'world'
ip = re.sub(host, "", host_ip)
print(ip)
translate()方法
host_ip = 'hello world'
host = 'world'
ip = host_ip.translate(str.maketrans("", "", host))
print(ip)