#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爬蟲:BeautifulSoup的 .find_all() 與 .find() 與 .select(‘標籤名[屬性名1=”屬性值1″][屬性名2=”屬性值2″]’) ; from bs4 import BeautifulSoup ; Live Server(可以預覽HTML的VS Code套件) Python爬蟲:BeautifulSoup的 .find_all() 與 .find() 與 .select(‘標籤名[屬性名1=”屬性值1″][屬性名2=”屬性值2″]’) ; from bs4 import BeautifulSoup ; Live Server(可以預覽HTML的VS Code套件)](https://i1.wp.com/savingking.com.tw/wp-content/uploads/2025/03/20250330190318_0_925655.jpg?quality=90&zoom=2&ssl=1&resize=350%2C233)








近期留言