【发布时间】:2018-08-26 04:14:13
【问题描述】:
如何让这个函数在第二次调用时不打印值c?我想要这个用于我的刽子手游戏。
像这样:
def myFunction(first,second,third):
if first == True:
# Do this
elif second == True:
c = third * 3
print(c) # I do not want this to print on the second time it run
return c
else:
print("Error")
【问题讨论】:
-
IDLE 仅当您在交互模式下运行代码时才会显示它。直接运行源码即可。
-
源代码是什么意思?
-
不打印某些东西可以通过不调用 print() 来实现。
-
@PaulCornelius 但我想说只在第一次打印
标签: python python-3.x function printing stateful