Python Clear List

Document 对象参考手册Python3 Examples

Define a list and clear it, which can be done using the clear() method.

Example 1

EXAMPLE = [6, 0, 4, 1]
print('Before clearing:', EXAMPLE)  
 
EXAMPLE.clear()
print('After clearing:', EXAMPLE)  

The output of the above example is:

清空前: [6, 0, 4, 1]
清空后: []

Document 对象参考手册Python3 Examples

Other Extensions