字典的一些基礎用法

2021-08-10 01:17:12 字數 767 閱讀 5528

#字典的一些基礎用法

dic=

#a. 請迴圈輸出所有的 key

foriindic.keys():

print(i) #k1k2k3

#b. 請迴圈輸出所有的 value

foriindic.values():

print(i) #v1v2[11, 22, 33]

#c. 請迴圈輸出所有的 key 和 value

fori,vindic.items():

print(i,v) #k1 v1 k2 v2 k3 [11, 22, 33]

#d. 請在字典中新增乙個鍵值對, "k4":"v4",輸出新增後的字典

dic['k4'] = 'v4'

print(dic) #

#e. 請在修改字典中 "k1" 對應的值為 "alex",輸出修改後的字典

dic['k1'] = 'alex'

print(dic) #

#f. 請在 k3 對應的值中追加乙個元素 44,輸出修改後的字典

print(dic) #

#g. 請在 k3 對應的值的第 1 個位置插入個元素 18,輸出修改後的字典

dic['k3'].insert(0

,18)

print(dic) #

numpy的一些基礎用法

import numpy as np x np.array 1 print x,x.ndim,x.shape x np.zeros 2,3,4 dtype np.int8 print x x np.ones 2,3 dtype np.int8 print x x np.arange 6 print ...

mysql 的用法 Mysql一些基礎用法

mysql建檢視 create view view name as select from table1 alter view view name as select from table1 建觸發器 create trigger trig name before insert on table n...

MySQL的一些基礎用法(筆記)

進入 mysql 庫 use mysql 建立資料庫 create database 資料庫名 檢視當前建立的資料庫 show create database 資料庫名 刪除資料庫 drop database 庫名 建立表 create table 表名 id int,name char 10 檢視...