
Python
Python语言的学习
syncdoodle
2020年写300篇博客!
展开
-
python中同时输出到终端和日志log文件
import sysclass Logger(object): def __init__(self, file_name = 'temp.log', stream = sys.stdout) -> None: self.terminal = stream self.log = open(f'log/{filename}', "a") def write(self, message): self.terminal.write(mess原创 2022-04-19 12:01:25 · 1951 阅读 · 1 评论 -
Python Parser的用法
import argparse# 1. 实例化ArgumentParserparser = argparse.ArgumentParser()## 2. 使用add_argument函数添加参数# ArgumentParser.add_argument(# name or flags... : — 选项字符串的名字或者列表,例如 foo 或者 -f, --foo。# [, action] : # [, nargs]: # [, const] :# [, default] : — 不指定原创 2022-03-30 21:34:33 · 1765 阅读 · 0 评论 -
Windows 10安装python及VScode的python环境配置
Windows 10安装python及VScode的python环境配置一、安装python二、VScode python环境配置一、安装python 下载python 安装python 注意选择Customize installation并勾选Add Python 3.8 to PATH。 检查是否安装成功 ...原创 2020-04-26 15:32:19 · 905 阅读 · 0 评论