Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python Exercise Example 9

Python Exercise Example 9

Python 100 Examples Python 100 Examples

**Problem:** Pause for one second before outputting.

**Program Analysis:** Use the sleep() function of the time module.

Program source code:

Example

#!/usr/bin/python

-- coding: UTF-8 --

import

time

myD

= {

1

:

'

a

'

,

2

:

'

b

'

}

for

key

,

value

in

dict

.

items

(

myD

)

:

print

(

key

,

value

)

time

.

sleep

(

1

)

Pause for 1 second

The output of the above example is (there will be a pause effect):


1 a
2 b

Python 100 Examples Python 100 Examples