嘿嘿,那是为了测试。显然它应该读为60.0(是浮动 必要吗?)。Heh heh, that was for testing. Obviously it should read 60.0 (is a floatnecessary at all?). John Salerno写道:John Salerno wrote:我开始学习C#时的第一个项目是制作一个小计时器,告诉我什么时候洗衣服完成:)我认为将它转换为Python会很有趣。这是我在使用线程模块中的Timer类进行了很多努力之后想出来的 - 正如你所看到的,我将它从计时器中放弃了sleep()函数。 如果这是一个好的(即Pythonic)方式,请告诉我,如果可以改进(虽然我不需要任何比这更基本的东西)功能)。 --------------------- 从时间导入睡眠 分钟=输入(''输入等待的分钟数:'') x范围(分钟):睡眠(1.0)分钟 - = 1 打印分钟, ''剩余时间。'' --------------------- My first project when I started learning C# was to make a little timer to tell me when my laundry was done :) and I thought it would be fun to convert this to Python. Here''s what I came up with after much struggling with the Timer class from the threading module -- as you can see, I abandoned it for the sleep() function from timer. Please let me know if this is a good (i.e. Pythonic) way of doing this, and if it can be improved (although I don''t need anything fancier than this basic functionality). --------------------- from time import sleep minutes = input(''Enter the number of minutes to wait: '') for x in range(minutes): sleep(1.0) minutes -= 1 print minutes, ''minutes remaining.'' --------------------- 非常好,但也许 .... 睡眠(60.0) 这可以纠正秒数一分钟。 詹姆斯 - James Stroud 加州大学洛杉矶分校-DOE基因组学和蛋白质组学研究所 Box 95157 0 洛杉矶,加利福尼亚州90095 http ://www.jamesstroud.com/控制台蜂鸣声怎么样?你怎么补充这个? rpdWhat about a console beep? How do you add that?rpd 这篇关于关于这个小脚本的建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-12 10:37