简体   繁体   English

如何在不使用模块的情况下让代码休眠

[英]How to make code sleep without using modules

I'm currently in a bit of a predicament, I'm trying to make a micro python program that has a small time delay for readability, but cannot use any imports.我目前处于困境,我正在尝试制作一个微型 python 程序,该程序的可读性时间延迟很小,但不能使用任何导入。 I would simply install the module onto the machine I'm working on, but the program is designed for the Casio-FX9860GIII Calculator.我只是将模块安装到我正在使用的机器上,但该程序是为 Casio-FX9860GIII 计算器设计的。

My first thought was to use a long calculation that takes the calculator a while to process, hence making the program "sleep" for a short period of time, but I've had no success with that.我的第一个想法是使用一个长时间的计算,需要计算器一段时间来处理,从而使程序“休眠”一小段时间,但我没有成功。 Does anyone have any ideas?有人有什么想法吗?

managed to figure it out, just used a for loop and did some testing using the Time function to get the timings right for my system, code looks like this设法弄清楚了,只是使用了一个 for 循环并使用 Time function 进行了一些测试以获得适合我的系统的时间,代码如下所示

def systemSleep(s):
        i = 0
        for i in range(0, s*45100000):
            3 * 3
            3 * 3
            3 * 3

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

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