|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 937135952 于 2020-8-11 16:34 编辑
有两个问题:问题1:代码如下
- c=10
- def one():
- x=1+1
- #print (x)
- return x
-
- def two(x):
- global c
-
- c=1+x+c
- print (c)
- return c
-
- def three(y):
- z=y+1
- print(z)
- for i in range(10):
- two(one())
- def four(b):
- a=b+1
- print (a)
- return a
- three(two(one()))
复制代码
能不能不用这种套娃的方式来执行代码.......我写了一个程序有十几个函数,然后就用这种方式来执行的。。。有没有其他的简洁的表示方法
问题二:代码如下
- c=10
- def one():
- x=1+1
- #print (x)
- return x
-
- def two(x):
- global c
-
- c=1+x+c
- print (c)
- return c
- def three(y):
- z=y+1
- print(z)
- for i in range(10):
- two(one())
- three(3)
- four(three())
- def four(b):
- a=b+1
- print (a)
- return a
复制代码
这里four(three())我想用three()执行过后,
for i in range(10):
two(one())
two()函数里return的c的值,但是这个值明显是在函数three()里了,我不懂要怎么传出来,即传到four()里,也就是我想实现four(c)
|
|