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
]*>.*?底下插入一個圖檔.*?</w:p>’, flags = re.DOTALL) ; new_xml, n = pattern.subn(”, xml, count=1)' title='Python正則替換:全面掌握 re.sub 與 re.subn 的差異與實戰 #substitute(替換); . 預設匹配「除\n以外的任意單一字元」; pattern = re.compile(r'<w:p[^>]*>.*?底下插入一個圖檔.*?</w:p>’, flags = re.DOTALL) ; new_xml, n = pattern.subn(”, xml, count=1)' loading='lazy' width=350 height=233 />
![Python Logging 完全指南:從基礎到實戰應用; import logging ; logging.basicConfig(level=logging.INFO, handlers=[ logging.StreamHandler(), logging.FileHandler(‘app.log’, mode=’a’, encoding=’utf-8′)] ) ; inspect.currentframe().f_code.co_name #動態取得funcName Python Logging 完全指南:從基礎到實戰應用; import logging ; logging.basicConfig(level=logging.INFO, handlers=[ logging.StreamHandler(), logging.FileHandler(‘app.log’, mode=’a’, encoding=’utf-8′)] ) ; inspect.currentframe().f_code.co_name #動態取得funcName](https://i1.wp.com/savingking.com.tw/wp-content/uploads/2025/10/20251021155823_0_c16012.png?quality=90&zoom=2&ssl=1&resize=350%2C233)
![Python: 如何在pandas.read_csv() or pandas.read_excel() 中使用keep_default_na =False , na_values =[] 保留文件中的原始“NA”? Python: 如何在pandas.read_csv() or pandas.read_excel() 中使用keep_default_na =False , na_values =[] 保留文件中的原始“NA”?](https://i1.wp.com/savingking.com.tw/wp-content/uploads/2024/05/20240530215737_0.png?quality=90&zoom=2&ssl=1&resize=350%2C233)






近期留言