简体   繁体   English

获取变量的延迟输出

[英]Get Delayed output of a variable

hey I have a Loop That is always running That keeps changing a variable Called X like this And It keeps running And keeps changing.嘿,我有一个一直在运行的循环,它像这样不断改变一个名为 X 的变量,它一直在运行,并且一直在变化。 And I want to get the previous output of the variable.我想获得变量的先前输出。 How Can I do this?我怎样才能做到这一点?

while True:
  X = X+10
  X = X*5
  
  print(X)

您可以将它们放在一个数组中并选择数组的最后一个元素

I assume this is what you're looking for when you say previous output of variable.当您说变量的先前输出时,我认为这就是您要查找的内容。 I'd suggest you to also read on loops if you've just started with python.如果你刚开始使用 python,我建议你也阅读循环。 Here's a source这是一个来源

while True:
    print(x) #this will print value X after each iteration 
    x= x+10
    x= x*5

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM