#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 `os.environ[“PATH”]`(設定 *.exe 路徑)vs `sys.path`(設定 *.py 路徑)教學:用 Whisper 與 ffmpeg 看懂兩種很像的 path Python `os.environ[“PATH”]`(設定 *.exe 路徑)vs `sys.path`(設定 *.py 路徑)教學:用 Whisper 與 ffmpeg 看懂兩種很像的 path](https://i2.wp.com/savingking.com.tw/wp-content/uploads/2026/05/20260513130826_0_8d5fb3.png?quality=90&zoom=2&ssl=1&resize=350%2C233)




近期留言