欧美成人午夜免费全部完,亚洲午夜福利精品久久,а√最新版在线天堂,另类亚洲综合区图片小说区,亚洲欧美日韩精品色xxx

千鋒扣丁學堂Python培訓之使用字典實現(xiàn)簡單記事本功能示例

2019-08-15 16:02:21 5166瀏覽

今天千鋒扣丁學堂Python培訓老師給大家分享一篇關于使用字典實現(xiàn)的簡單記事本功能示例,結合實例形式分析了基于字典的數(shù)據(jù)存儲、讀取、刪除等相關操作技巧,下面我們一起來看一下吧。



from time import sleep, strftime
user = "Cytus"
calendar = {}
def welcome():
  print "Welcome to use this calendar. %s" % user
  print "Calendar is opening."
  sleep(1)
  print strftime("%A %B %d %Y")
  print strftime("%H:%M:%S")
  sleep(1)
  print "What would you like to do?"
def start_calendar():
  welcome()
  start = True
  while start:
    user_choice = raw_input("A to add, U to Update, V to View, D to Delete, X to Exit: ")
    user_choice = user_choice.upper()
    if user_choice == "V":
      if len(calendar.keys()) < 1:
        print "The calendar is empty."
      else:
        print calendar
    elif user_choice == "U":
      date = raw_input("What date? ")
      update = raw_input("Enter the update: ")
      calendar[date] = update
      print "Update successful."
      print calendar
    elif user_choice == "A":
      event = raw_input("Enter event: ")
      date = raw_input("Enter date (MM/DD/YYYY): ")
      if (len(date) > 10) or int(date[6:]) < int(strftime("%Y")):
        print "invaild date."
        try_again = raw_input("Try again? Y for yes, N for No: ")
        try_again = try_again.upper()
        if try_again == "Y":
          continue
        else:
          start = False
      else:
        calendar[date] = event
        print "Successfully added."
        print calendar
    elif user_choice == "D":
      if len(calendar.keys()) < 1:
        print "The calendar is empty."
      else:
        event = raw_input("What event? ")
        for date in calendar.keys():
          if calendar[date] == event:
            del calendar[date]
            print "Delete successfully."
            print calendar
          else:
            print "incorrect event was specified."
    elif user_choice == "X":
      start = False
    else:
      print "invalid input."
      start = False
start_calendar()

以上就是關于千鋒扣丁學堂Python培訓之使用字典實現(xiàn)簡單記事本功能示例的全部內(nèi)容,想要了解更多關于Python和人工智能方面內(nèi)容的小伙伴,請關注扣丁學堂Python培訓官網(wǎng)、微信等平臺,扣丁學堂IT職業(yè)在線學習教育平臺為您提供權威的Python開發(fā)環(huán)境搭建視頻,Python培訓后的前景無限,行業(yè)薪資和未來的發(fā)展會越來越好的,扣丁學堂老師精心推出的Python視頻教程定能讓你快速掌握Python從入門到精通開發(fā)實戰(zhàn)技能??鄱W堂Python技術交流群:279521237。


扣丁學堂微信公眾號                          Python全棧開發(fā)爬蟲人工智能機器學習數(shù)據(jù)分析免費公開課直播間


      【關注微信公眾號獲取更多學習資料】         【掃碼進入Python全棧開發(fā)免費公開課】



查看更多關于"Python開發(fā)資訊"的相關文章>

標簽: Python培訓 Python視頻教程 Python在線視頻 Python學習視頻 Python培訓班

熱門專區(qū)

暫無熱門資訊

課程推薦

微信
微博
15311698296

全國免費咨詢熱線

郵箱:codingke@1000phone.com

官方群:148715490

北京千鋒互聯(lián)科技有限公司版權所有   北京市海淀區(qū)寶盛北里西區(qū)28號中關村智誠科創(chuàng)大廈4層
京ICP備2021002079號-2   Copyright ? 2017 - 2022
返回頂部 返回頂部