Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个功能:
def user_login(m): m = "user_login function called" return m
调用它:
user_login(message)
它应该改变一个字符串 m,并返回结果。我知道该函数会被调用,因为如果我没有在其中添加参数,它会引发错误 [user_login() 恰好采用 1 个参数(给定 0)]。但它不返回字符串。我怎样才能找出问题所在?
您不能“更改字符串”-相反,您应该做的是将函数的结果分配给调用范围内的字符串:
m = user_login('some message') print m