Python 示例 饮水记录
因为每天都需要喝水 这是非常重要的
目录结构:
├─bin
│ │ start.py
│ │
│ └─__pycache__
│ start.cpython-36.pyc
│
├─core
│ │ src.py
│ │
│ └─__pycache__
│ src.cpython-36.pyc
│
└─log
access.log
代码内容:
start.py
"""
Description:
Author:Nod
Date:
Record:
#---------------------------------v1-----------------------------------#
""" import os,sys BASE_DIR=os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
#拿到整个文件的当前路径D:\Document\Python0404\day5\目录规范\ATM2
sys.path.append(BASE_DIR)#添加到环境变量
LOG_PATH=os.path.join(BASE_DIR,'log','access.log') from core import src if __name__=='__main__':
src.run()
src.py
"""
Description:
Author:Nod
Date:
Record:
#---------------------------------v1-----------------------------------#
"""
from bin import start import time
# 记录喝水的记录
def record():
time_strf=time.asctime()
msg='Nod has drink at %s'%time_strf
with open(start.LOG_PATH, 'a', encoding='utf-8') as f:
f.write('%s\n' % msg) #查看喝水的时间
def checkRecord():
with open(start.LOG_PATH, 'r', encoding='utf-8') as f2:
data=f2.read()
print('==========================>查看饮水记录<=========================')
print(data)
print('==========================>饮水记录结束<=========================')
#退出程式
def Quit():
exit('退出程式') def run():
message = """ welcome to drink water record 1 record
2 checkRecord
3 Quit """
while True:
print(message)
user_choice=input('请输入你的选择:>>>>').strip()
if not user_choice:continue
if user_choice=='':
record()
elif user_choice=='':
checkRecord()
elif user_choice=='':
Quit() if __name__=='__main__':
run()
Python 示例 饮水记录的更多相关文章
- Python爬虫个人记录(三)爬取妹子图
这此教程可能会比较简洁,具体细节可参考我的第一篇教程: Python爬虫个人记录(一)豆瓣250 Python爬虫个人记录(二)fishc爬虫 一.目的分析 获取煎蛋妹子图并下载 http://jan ...
- Python爬虫个人记录(二) 获取fishc 课件下载链接
参考: Python爬虫个人记录(一)豆瓣250 (2017.9.6更新,通过cookie模拟登陆方法,已成功实现下载文件功能!!) 一.目的分析 获取http://bbs.fishc.com/for ...
- python 示例代码1
第一章 python基础一 在此不再赘述为什么学习python这门编程,网上搜索一箩筐.我在此仅说一句python的好,用了你就会爱上它. 本python示例代码1000+带你由浅入深的了解pyth ...
- Python爬虫学习记录【内附代码、详细步骤】
引言: 昨天在网易云课堂自学了<Python网络爬虫实战>,视频链接 老师讲的很清晰,跟着实践一遍就能掌握爬虫基础了,强烈推荐! 另外,在网上看到一位学友整理的课程记录,非常详细,可以优先 ...
- Python常用函数记录
Python常用函数/方法记录 一. Python的random模块: 导入模块: import random 1. random()方法: 如上如可知该函数返回一个[0,1)(左闭右开)的一个随机的 ...
- python & mongo问题记录
背景介绍 使用python操作mongo进行的一些操作记录,为了方便日后可以快速的解决类似问题. 准备工作 为了尽可能简单的说明,我将插入几条简单的数据. from pymongo import Mo ...
- 示例开发过程记录:meteor,react,apollo
本示例记录一个开发过程: 1)参考 Meteor React TUTORIAL教程 https://www.meteor.com/tutorials/react/creating-an-app 2). ...
- python 文本编辑基础记录
不熟悉编码方式,同时python的编码方式折磨我了很长时间,记录下,以免忘记,本文内容存在错误,是自己理解,看到仅当参考 Unicode 是字符集,有点像一本字典,utf-8是在unicode这本字典 ...
- Python简单爬虫记录
为了避免自己忘了Python的爬虫相关知识和流程,下面简单的记录一下爬虫的基本要求和编程问题!! 简单了解了一下,爬虫的方法很多,我简单的使用了已经做好的库requests来获取网页信息和Beauti ...
随机推荐
- Swift网络封装库Moya中文手册之Targets
Targets 使用Moya,我们首先需要定义一个target - 这通常是继承 TargetType 协议的 枚举 变量.接下来,你的app只需要处理这些targets,也就是一些你希望调用API完 ...
- css 课堂笔记
css:层叠样式表 Cascading( [kæ'skeɪdɪŋ] 级联)Style Sheet css基本语法结构:选择器{ 属性:值; 属性:值: ... } 三种主要的选择器: 标签选择器: ...
- ZOJ2540 Form a Square
Form a Square 题意就是 判断 给你四个点,能否组成一个正方形 要点: 格式很重要, 很重要!!! 数据很小,直接暴力 四个点判断是否为正方形,只需将所有可能的边长度算出来,然后选其中最短 ...
- Enginering English for interview (1)
I was lucky to work in a foreign company, Here is an overview of the interview test : 1.Because of t ...
- c# 进程调用exe
using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostic ...
- jsp 中实现点击按钮 实现页面跳转到HTML
<input type ="button" value="跳转" onclick="window.location.href='main.htm ...
- JSP--TOMCAT-MYSQL web页面查询
queryStudent.jsp代码如下 <%@ page language="java" contentType="text/html; charset=gb23 ...
- magento的xml文件解读
其中显示页面的getChildHtml(’')函数是取xml文件中的block中的name属性的:
- 强化学习 平台 openAI 的 gym 安装 (Ubuntu环境下如何安装Python的gym模块)
openAI 公司给出了一个集成较多环境的强化学习平台 gym , 本篇博客主要是讲它怎么安装. openAI公司的主页: https://www.openai.com/systems/ 从主页上我 ...
- 【linux】wifi不能使用的问题
Worked solution (Requirements: kernel >=4.11) : Download driver directory from this repo:https:// ...