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