python: how to change the value of function's input parameter?
问题 I tried to modify the value of a string inside a function, like below: >>> def appendFlag(target, value): ... target += value ... target += " " ... >>> appendFlag <function appendFlag at 0x102933398> >>> appendFlag(m,"ok") >>> m '' Well, seems the "target" is only changed within the function, but how to make the new value viable outside the function? Thanks. 回答1: This is handled in python by returning. def appendFlag(target, value): target += value target += " " return target you can use it