python基础
Hou_Monkey
你若盛开 清风徐来
展开
-
python pandas excle 把两列合并新的一列
好久没更新了 昨天遇到糟心事 处理excle 时间 问题 哎 记得之前写过这类脚本 哎 找不到了 网上资料真是尴尬… 直接上我代码 效果如下如所示import pandas as pd# 使用pandas读取excel文件def handle_file(file_name): try: file = "./" + file_name + ".XLS" df = pd.read_excel(file) # 读取excle文件 time原创 2021-05-26 10:57:02 · 5694 阅读 · 2 评论 -
python 图片转化为base64
直接写的例子如下:image_path = r"D:\PycharmProjects\mirrors-odoo-14.0\odoo\Images\美女.png"with open(image_path, 'rb') as f: image = f.read() image_base64 = str(base64.b64encode(image), encoding='utf-8')原创 2021-04-09 11:49:08 · 314 阅读 · 0 评论 -
python os 怎样使用 读取一个文件中所有图片的名称
有时候要批量读取一个文件中的图片名称 把名称放在一个字典中 怎样搞 直接上代码 … image_path = r"D:\PycharmProjects\mirrors-odoo-14.0\odoo\Images" if os.path.isdir(image_path): img_infos = os.listdir(image_path) print(img_infos)...原创 2021-04-09 11:39:54 · 1229 阅读 · 0 评论 -
python中二维码得生成
python 二维码生成方法 代码如下def generate_two_dimensional_code(contents, name): """ :param contents: 生成二维码内容 :param name: 密文 为图片拼接加密图片路径 :return: 返回二维码图片的绝对路径 """ # 创建一个对象 qr = qrcode.QRCode( version=1, error_correction=原创 2020-12-04 16:25:44 · 157 阅读 · 1 评论 -
python在得到绝对路径时候 \ 转化/
在python中想要得到文件或图片路径时候往往会\ 发生转义 例如:如图所示怎样得到下图 代码如下 s = "XXXXXX" new_qr_img_path = s.replace("\\", "/") print(new_qr_img_path)原创 2020-12-01 17:33:15 · 1139 阅读 · 0 评论 -
python中时间日期相减并转化为秒
python在时间日期转化时候怎样相减转化 秒 ,刚有人咨询我这些问题,写了一些代码 希望对你有点用from datetime import datetimenow_time = datetime.now()now_time = now_time.strftime("%Y-%m-%d %H:%M:%S")now_time = datetime.strptime(now_time, r"%Y-%m-%d %H:%M:%S")print("当前时间", now_time)print(type(no原创 2020-10-15 10:09:15 · 9423 阅读 · 2 评论