[英]How can I use str in time.sleep()?
import time
t = 10
time.sleep(t)
This is an example. 这是一个例子。 I need to put str in time.sleep() but it gives me Attribute error: "str" object has no attribute "sleep"
我需要将str放入time.sleep()中,但是它给了我属性错误:“ str”对象没有属性“ sleep”
Type cast your string via int(my_str_time)
. 通过
int(my_str_time)
输入类型int(my_str_time)
。 Though this may be a hint that sitting through a python tutorial will be extremely useful. 尽管这可能暗示坐在python教程中将非常有用。
It must be converted to an int. 必须将其转换为int。
new_t = int(t)
time.sleep(new_t)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.