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.
我想以 1 微秒的步长制作一个从 0 到 2.097152 秒的计数器。
我尝试使用 time.sleep() 但这不是正确的解决方案
我使用 Python 3.x
感谢您的帮助
你可以搜索[python] range float
[python] range float
但无论如何:
def msrange(start, stop, step=0.000001): while start <= stop: yield round(start, 6) if start + step > stop: yield stop start += step
那么你就可以:
for i in msrange(0, 0.00003): print(i)
输出:
0 1e-06 2e-06 3e-06 ... 3e-05