python函数返回值

#不带参数
def a1():
print(“a1”)
def a2():
print(“a2”)
return “This is a2”
def a3():
print(“a3”)
return “This is a3”
print(“hi!”)

i = a1()
print(i)
j = a2()
print(j)
k = a3()
print(k)

#带参数
def testReturn(input1):
for i in range(input1):
return i
def testPrint(input1):
for i in range(input1):
print(i)
n = 3
value1 = testReturn(n)
print(‘testReturn return value = %s’% value1)

print(’*’ * 15)

value2 = testPrint(n)
print(‘testPrint return value = %s’% value2)

你可能感兴趣的:(python函数返回值)