Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 RhinoPython 中输入一个数字滑块来增加 y 值。当 y 等于某个值时,我希望反转增量。我已经想出了如何让它消极,但这不是我所追求的。对不起,这个问题很简单,谢谢。简而言之,数字滑块会增加变量,一旦达到 45,它就会随着数字滑块的每次增量而倒计时。
len = 45 inc = float(.1) if y >= len: y *= -inc print (y)
首先,不要调用变量len,因为它是标准库函数的名称。如果我正确理解了这个问题,代码将是
len
threshold = 45 inc = .1 y = 0 while True: # goes forever, put your own code here if y >= threshold: inc *= -1 y += inc print (y)
y 达到 45 后,开始倒计时。倒计时没有停止条件,这里是无限循环