[英]Python return variable defined with raw_input
i wonder how to pass some variable through functions with return in python, if one function starts with raw_input like this: 我想知道如何通过python中的return通过函数传递一些变量,如果一个函数以raw_input开头,如下所示:
def function1():
a = raw_input("Type something: ")
return a
def function2():
b = function1() #i want b to get value of a
When i try this and try to print "b" it just shows me again "Type something: " and again and again 当我尝试此操作并尝试打印“ b”时,它只会再次显示“输入内容:”
You need to call function2 您需要调用function2
def function1():
a = raw_input("Type something: ")
return a
def function2():
b = function1()
print b
function2()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.