Python Sample drinking water record

Source: Internet
Author: User

Because it's important to drink water every day.

Directory structure:

├─bin
││start.py
││
│└─__pycache__
│start.cpython-36.pyc

├─core
││src.py
││
│└─__pycache__
│src.cpython-36.pyc

└─log
Access.log

Code content:

start.py

1 """2 Description:3 Author:nod4 Date:5 Record:6 #---------------------------------v1-----------------------------------#7 """8 9 ImportOs,sysTen  One  ABase_dir=os.path.dirname (Os.path.dirname (Os.path.abspath (__file__))) - #get the current path to the entire file D:\Document\Python0404\day5\ directory specification \atm2 -Sys.path.append (Base_dir)#Add to environment variable theLog_path=os.path.join (Base_dir,'Log','Access.log') -  -  fromCoreImportsrc -  + if __name__=='__main__': -Src.run ()
View Code

src.py

1 """2 Description:3 Author:nod4 Date:5 Record:6 #---------------------------------v1-----------------------------------#7 """8  fromBinImportStart9 Ten  One  A Import Time - #record the drinking water record - defrecord (): thetime_strf=time.asctime () -msg='Nod have drink at%s'%TIME_STRF -With open (start. Log_path,'a', encoding='Utf-8') as F: -F.write ('%s\n'%msg) +  - #Check the time of drinking water + defCheckrecord (): AWith open (start. Log_path,'R', encoding='Utf-8') as F2: atData=F2.read () -     Print('==========================> View drinking water records <=========================') -     Print(data) -     Print('==========================> drinking Water Records end <=========================') - #Exit Program - defQuit (): inExit'Exit Program') -  to  + defrun (): -Message =""" the  * Welcome to drink water record $ Panax Notoginseng 1 record - 2 Checkrecord the 3 Quit +  A     """ the      whileTrue: +         Print(message) -User_choice=input ('Please enter your choice:>>>>'). Strip () $         if  notUser_choice:Continue $         ifuser_choice=='1': - record () -         elifuser_choice=='2': the Checkrecord () -         elifuser_choice=='3':Wuyi Quit () the  -  Wu  -  About if __name__=='__main__': $Run ()
View Code

Python Sample drinking water record

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.