![](/img/trans.png)
[英]Print all except the fourth item from a five item list for two lists next to each other Python
[英]Print each item in list one second after the other (PYTHON)
說我有一個n
項目的清單,我想一個接一個地打印,每一個之間打印一秒鍾
說n = 5
:
list = [a,b,c,d,e]
我想做“打印清單”
a
...1 second...
b
..1 second...
c
...etc...
我嘗試弄亂計時器功能,但是我不確定該怎么做
x = [a,b,c,d,e,f]
for i in x
print x
PS C:\\PYthon\\A06> python -i test.py
使用time.sleep
:
>>> import time
>>> lis = ['a', 'b', 'c', 'd', 'e']
>>> for x in lis:
... print x
... time.sleep(1)
...
a
b
c
d
e
time.sleep
幫助time.sleep
:
sleep(seconds)
Delay execution for a given number of seconds. The argument may be
a floating point number for subsecond precision.
使用time.sleep()
函數可在給定時間內暫停執行:
import time
x = ['a', 'b', 'c', 'd', 'e', 'f']
for i in x:
print i
time.sleep(1)
time.sleep()
一個數字參數,即“睡眠”的秒數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.