Python3實現簡單的記單詞功能__Python

來源:互聯網
上載者:User

(不使用資料庫)實現一個簡單的記生單詞軟體,準系統包括:添加新的單詞及其中文含義,瀏覽已經記錄過的單詞,隨機播放單詞進行複習。可考慮其他拓展的功能。

#coding=utf-8import randoma=dict()f=1def addword():    n=input("請輸入這個單詞:")    x=input("請輸入中文意思:")    a[n]=xdef showall():    print(a)def show():    print("1.查詢所有的單詞")    print("2.添加單詞")    print("3.查詢特定的單詞")def specialword():    n = input("請輸入這個單詞:")    if n in a.keys():        print(a.get(n))    else:        print("沒有這個單詞")        addword()def review():    print(random.sample(a.keys(),1))while(f):    show()    x=input("請選擇序號:")    if x=='1':        showall()    elif x=='2':        addword()    elif x=='3':        specialword()    else:        print("輸入有誤")    c=input(" 是否繼續。(y/n):")    if c=='y' or c=='Y':        f=1    else:        f=0review()

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.