![](https://img-blog.csdnimg.cn/20210716155411690.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
python基础
python基础
阿吉的CV之路
为山者基于一篑之土,以成千丈之峭
凿井者起于三寸之坎,以就万仞之深
展开
-
python+apscheduler定时上传实现
python定时上传实现定时随机上传一张图片import requestsimport osfrom apscheduler.schedulers.blocking import BlockingSchedulerimport randomfrom PIL import Imageimport timefrom pathlib import Pathimport cv2 as cvimport timedef post_url(): url = "http://localh原创 2021-10-15 10:37:49 · 211 阅读 · 0 评论 -
python基础记录
python基础记录osPathstryamlpath = “D:/”os#split the name of file and the extension name,ep"file.txt",file is file name,.txt is extension name1.os.path.splitext(“123.jpg”)[out]: ["123",".jpg"]# accumulate the size of file2.os.path.getsize(path)if os.原创 2021-10-11 17:21:58 · 248 阅读 · 0 评论 -
python--argparse之action用法
argparse之action用法action关键字默认状态有两种,store_true和store_false,若输入命令时,不指定其参数,则store_true显示为False,store_false显示为True。下面举个例子来直观感受一下.import argparseimport osfrom pathlib import Pathparse = argparse.ArgumentParser()parse.add_argument("--a", action="store_true原创 2021-10-04 20:41:12 · 6897 阅读 · 3 评论 -
Python读取文件找出重复元素
Python读取文件找出重复元素import osnum_list = ""path = "D:/num.txt"with open("D:/duplicate.txt", 'w') as f: f.write("a、b、c、d、c、c、f、c、d、e")with open("D:/duplicate.txt", 'r') as f: line = f.readlines() print(f"total_line:{line}")paths = "D:/duplicat原创 2021-09-04 15:59:11 · 4196 阅读 · 0 评论 -
python全局变量global用法
python全局变量global用法coderesultcodex = 5def run(): global x x += 1def img(): global x x += 2 run()img()print(x)result8global作用在于在函数内部修改全局变量,在不同函数修改必须要在函数中使用global声明此变量...原创 2021-07-09 15:02:11 · 476 阅读 · 0 评论 -
python获取当前时间
使用time模块获取当前时间 import time import re def now_time(): time_now = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()) return time_now time_str = now_time() time_transformer = re.sub(' ', '-', time_str, 1) time_modi原创 2021-05-14 11:56:05 · 86 阅读 · 0 评论 -
Python装饰器学习
装饰器代码输出解释Decorator作用在于增强函数而不改变函数本身的含义代码from functools import wraps def log(text): def decorator(func): @wraps(func) def wrapper(*args, **kwargs): print(f'{text} func:{func.__name__}')原创 2021-05-14 11:51:12 · 91 阅读 · 0 评论