如何执行def命令而不显示无 [英] How to execute def command without showing None
本文介绍了如何执行def命令而不显示无的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图让一个函数运行另一个函数,然后询问输入。
当我使用打印选项时,它在执行def后返回 None
,但是当我使用返回选项时,它仅打印print_board(板)如何在不显示 None的情况下执行命令
并没有完成该功能?
def main():
print print_board(board)
x = int (raw_input(Enter row))
y = int(raw_input(Enter column))
z = int(raw_input(Enter digit))
return is_valid_move(x,y, z)
解决方案
b
def main():
print_board(board)
...
这将调用 print_board()
,但不会打印出它的返回值(无
)也不终止 main()
。
I'm trying to make a function run another function and then ask for input.
The thing is that when I use the print option it returns None
after exectuing the def, but when I use the return option it just prints the print_board(board) and finishes the function, meaning, without asking for the inputs.
How can I execute a command without showing None
and without finishing the function?
def main():
print print_board(board)
x = int(raw_input("Enter row "))
y = int(raw_input("Enter column "))
z = int(raw_input("Enter digit "))
return is_valid_move(x,y,z)
解决方案
Simply:
def main():
print_board(board)
...
This will call print_board()
, but will neither print out its return value (None
) nor terminate main()
.
这篇关于如何执行def命令而不显示无的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文