字典變數名稱.clear()
範例:
- # -*- coding: utf-8 -*-
- """
- Created on Wed Jan 23 19:52:59 2019
- @author: 軟體罐頭
- """
- stock = {'1101':'台泥','1102':'亞泥','1103':'嘉泥','1104':'環泥','1108':'幸福','1109':'信大','1110':'東泥'}
- print('原來的字典元素內容:',stock)
- print()
- stock.clear()
- print('清空後的字典元素內容:',stock)
執行結果: