当我调用静态类方法时,为什么会收到“Type 'str' does not have Expected attribute '__setitem__'”?
@staticmethod
def replace_region_decimal_sign(to_convert):
to_convert[to_convert.index(',')] = '.' # Replace comma ("region" decimal sign) with a dot
return to_convert
if __name__ == "__main__":
print(Calculator.replace_region_decimal_sign("1,23"))
为什么不使用替换?
to_convert.replace(",", ".")