#Python dict()製作menu
dic = {}
def add():
print(“Input key: “,end=””)
k = eval(input())
print(“Input value: “,end=””)
v=input()
if k not in dic : dic[k] = v
else: print(“The key is already existed”)
def delete():
print(“Input key: “,end=””)
k = eval(input())
if k in dic :
dic.pop(k)
print(str(k) + ” has been deleted”)
else : print(“The key is not found”)
def query():
print(“Input key: “,end=””)
k = eval(input())
if k in dic : print(dic.get(k))
else : print(“The key is not found”)
def display():
for key in dic:
print( str(key)+”:” +str(dic[key]))
def menu():
print()
print(“1: add”)
print(“2: delete”)
print(“3: query”)
print(“4: display”)
print(“5: exit”)
print(“Which one: “,end=” “)
def main():
while True:
menu()
choice = eval(input())
if choice == 1 : add()
elif choice == 2 : delete()
elif choice == 3 : query()
elif choice == 4 : display()
elif choice == 5 : break
else: print(“Try again”)
main()



![Python 讀取 DOCX 圖片關聯:qn+find/findall 與 XPath 的實戰對照 from lxml import etree ; from docx.oxml.ns import qn; lxml.etree._Element.findall( f”.//{ qn(‘a:blip’) }” ) ; .get( qn(“r:embed”) ) #獲取 屬性名 ‘r:embed’ 的 屬性值(如: ‘rId4’) ; lxml.etree._Element.xpath( “//a:blip/@r:embed”, namespaces = NS) #/@r:embed = 獲取 屬性名 ‘r:embed’ 的 屬性值(如: ‘rId4’),使用.findall() 要先.findall()獲取List[_Element],再迴圈_Element.get()獲取屬性值, .xpath() 第一個參數path 使用”//a:blip/@r:embed” ,可直接獲取屬性值(List[str]如: [‘rId4’, ‘rId5’]) ; 如何對docx真實移除圖片瘦身? Python 讀取 DOCX 圖片關聯:qn+find/findall 與 XPath 的實戰對照 from lxml import etree ; from docx.oxml.ns import qn; lxml.etree._Element.findall( f”.//{ qn(‘a:blip’) }” ) ; .get( qn(“r:embed”) ) #獲取 屬性名 ‘r:embed’ 的 屬性值(如: ‘rId4’) ; lxml.etree._Element.xpath( “//a:blip/@r:embed”, namespaces = NS) #/@r:embed = 獲取 屬性名 ‘r:embed’ 的 屬性值(如: ‘rId4’),使用.findall() 要先.findall()獲取List[_Element],再迴圈_Element.get()獲取屬性值, .xpath() 第一個參數path 使用”//a:blip/@r:embed” ,可直接獲取屬性值(List[str]如: [‘rId4’, ‘rId5’]) ; 如何對docx真實移除圖片瘦身?](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2025/11/20251119130848_0_3fbf6b.png?quality=90&zoom=2&ssl=1&resize=350%2C233)


![Python網路爬蟲requests 如何下載台灣證交所的opendata? rawData = requests. get (inputs) #<Response [200]> Python網路爬蟲requests 如何下載台灣證交所的opendata? rawData = requests. get (inputs) #<Response [200]>](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2022/10/20221004135740_43.png?quality=90&zoom=2&ssl=1&resize=350%2C233)





近期留言