我是一个新来的python,所以这个问题可能有一个简单的答案,但是我看了之后什么也没发现。你知道吗
我想定义一个函数,当它被输入时:“function(function(fegg123,fg1,”)”返回值是:“feg123”。我想应该是这样的:
def function(something, what_to_deleat, what_to_substitute):
if str(what_to_deleat) in str(something):
return ## Code that replaces "what_to_deleat" with "what_to_substitute" within "something"
else:
return something
如果输入“function”(“25.0”、“.0”、“)”,一个实际应用程序(我想用这个)会将25.0转换成25。你知道吗
我想最简单的解决办法是
当然你不需要在这里写你自己的函数。。。你知道吗
见https://docs.python.org/2/library/string.html#string.replace
相关问题 更多 >
编程相关推荐