dic = {“k1″:”v1″,”k2″:”v2”}
key = dic.keys()
“””
#像list(有序),但無法使用key[0]
#TypeError: ‘dict_keys’ object is not subscriptable(可下標的)
可使用keyLst = [k for k in key],轉為真正的list
#set(dic)也可取出所有key, type為set (無序)
“””
value = dic.values()
item = dic.items()
print(“key:”,key,type(key))
print(“value:”,value,type(value))
print(“item:”,item,type(item))
for k in key:
print(k)
for v in value:
print(v)
for it in item:
print(it)

type(dicIn.keys):
builtin_function_or_method

.keys()是一個函式或方法
回傳一個list-like的資料
所以後面需要()
推薦hahow線上學習python: https://igrape.net/30afN
![Python: pandas.DataFrame (df) 的取值: df [單一字串] 或df [list_of_strings] 選取一個或多個columns; df [切片] 或 df [bool_Series] 選取多個rows #bool_Series長度同rows, index也需要同df.index ,可以使用.equals() 確認: df.index.equals(mask.index) Python: pandas.DataFrame (df) 的取值: df [單一字串] 或df [list_of_strings] 選取一個或多個columns; df [切片] 或 df [bool_Series] 選取多個rows #bool_Series長度同rows, index也需要同df.index ,可以使用.equals() 確認: df.index.equals(mask.index)](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2025/04/20250420212553_0_6fb2c3.png?quality=90&zoom=2&ssl=1&resize=350%2C233)









近期留言