def user_input():
numb = input("Input number ") # bind result of the input function
# to local variable "numb"
numb_process(numb) # pass the object bound to "numb"
# to called function
def numb_process(some_number): # bind inbound object to local variable
# "some_number"
if some_number == '1': # use bound object in calculations
print("Good")
else:
print("Bad")
user_input()
这是python101,标准python tutorial是学习基本概念的好地方。在您的例子中,简单的参数传递就可以了。你知道吗
应该有用。您可以通过给它一个参数“numb”来调用numb\u process函数,该参数将从函数“user\u input”移动到函数“numb\u process”。你知道吗
相关问题 更多 >
编程相关推荐