随笔分类 -  Python轮子

摘要:# 提示 def smtpSend(mail_msg): Q = "你的QQ号" # 邮箱服务器及认证信息 mail_host = "smtp.qq.com" mail_user = f"{Q}@qq.com" mail_pass = "邮箱秘钥" # 发件人和收件人 sender = f"{Q}@ 阅读全文
posted @ 2024-12-06 15:05 PythonNew_Mr.Wang 阅读(37) 评论(0) 推荐(0) 编辑
摘要:def ts_download(base_url,start,end): """ base_url: 下载地址 start : 开始文件名 end : 结束文件名 """ import requests for i in range(start, end + 1): # 4个字符,0补充空位,I为变 阅读全文
posted @ 2024-08-09 22:56 PythonNew_Mr.Wang 阅读(40) 评论(0) 推荐(0) 编辑
摘要:import paramiko # 获取信息 def check_msg(hostname,username,password): # 创建 SSH 客户端实例 ssh_client = paramiko.SSHClient() ssh_client.set_missing_host_key_pol 阅读全文
posted @ 2024-03-23 12:47 PythonNew_Mr.Wang 阅读(77) 评论(0) 推荐(0) 编辑
摘要:获取文件夹下的所有文件名,文件大小,更新时间 import os import datetime def get_files_info(folder_path): files_info = [] # 获取起始路径 base_path = os.path.abspath(folder_path) # 阅读全文
posted @ 2024-01-18 10:55 PythonNew_Mr.Wang 阅读(49) 评论(0) 推荐(0) 编辑
摘要:支持中文编码 import os import shutil import tarfile import zipfile import gzip # 解压压缩包 def support_gbk(zip_file): """ 支持中文编码 """ name_to_info = zip_file.Nam 阅读全文
posted @ 2024-01-18 10:53 PythonNew_Mr.Wang 阅读(391) 评论(0) 推荐(0) 编辑
摘要:协议 gRPC(Google Remote Procedure Call)是一种高性能、开源的远程过程调用(RPC)框架,由Google开发并开源。它基于HTTP/2协议进行通信,使用Protocol Buffers(protobuf)作为接口定义语言(IDL)。 gRPC提供了跨平台、跨语言的服务 阅读全文
posted @ 2023-12-13 13:59 PythonNew_Mr.Wang 阅读(93) 评论(0) 推荐(0) 编辑
摘要:### 1:简单创建添加文字到图片 ```python from PIL import Image, ImageDraw, ImageFont, ImageFilter # 导入PIL库中的相关模块 import random # 导入random库 # 创建一个图片对象 (200, 100) 为 阅读全文
posted @ 2023-08-01 16:55 PythonNew_Mr.Wang 阅读(239) 评论(0) 推荐(0) 编辑
摘要:# 月份 def get_next_n_months(date_str,n): from datetime import datetime, timedelta input_date = datetime.strptime(date_str, "%Y-%m") next_six_months = [ 阅读全文
posted @ 2023-02-14 18:33 PythonNew_Mr.Wang 阅读(103) 评论(0) 推荐(0) 编辑
摘要:```python import datetime # 当前日期 def today_date(): return datetime.datetime.now().date() # 上周一 def last_monday(): return str(datetime.datetime.now() - 阅读全文
posted @ 2022-11-19 13:53 PythonNew_Mr.Wang 阅读(355) 评论(0) 推荐(0) 编辑
摘要:```python import numpy as np def dict_to_dicts(origin: dict, n: int): """ :param origin: 被拆封的字典 :param n: 被拆分几个 :return: 返回列表包字典 """ n -= 1 keys = lis 阅读全文
posted @ 2022-09-14 13:20 PythonNew_Mr.Wang 阅读(461) 评论(0) 推荐(0) 编辑
摘要:1:基础理解异步如何实现的 # 请记住async创建的对象一定是coroutine对象 async def func(name): res = random.randint(1,10) print("{}需要{}秒".format(name,res)) # await 后面一定是coroutine对 阅读全文
posted @ 2022-09-09 16:33 PythonNew_Mr.Wang 阅读(166) 评论(0) 推荐(0) 编辑
摘要:import random def split_int(amount,num): """ :param amount: 拆分的数字 54782 :param num: 拆分成几组 4 :return: 拆分后得到的数组 [11001, 6085, 9494, 28202] """ list1 = [ 阅读全文
posted @ 2022-06-17 14:40 PythonNew_Mr.Wang 阅读(661) 评论(0) 推荐(0) 编辑
摘要:def random_code_six(): """ :return 58yWNl """ str = "" for i in range(6): code = random.randrange(3) if code == 0: ch = chr(random.randrange(ord("A"), 阅读全文
posted @ 2022-05-25 14:04 PythonNew_Mr.Wang 阅读(41) 评论(0) 推荐(0) 编辑
摘要:# 输入字符串 返回加密数据 def md5_func(parameters): """ :USE: Encryption Data :param: String :return 9cd6afb07d85b28ead0cecd99c317158 """ ctime = str(time.time() 阅读全文
posted @ 2022-05-25 14:02 PythonNew_Mr.Wang 阅读(81) 评论(0) 推荐(0) 编辑
摘要:from wordcloud import ImageColorGenerator from matplotlib.image import imread import matplotlib.pyplot as plt # 输出分词组合 ciyun_str = ciyun_word_str(ciyu 阅读全文
posted @ 2022-05-07 11:44 PythonNew_Mr.Wang 阅读(99) 评论(0) 推荐(0) 编辑
摘要:def word_counts_action(text, top_number): """ :param text: 统计的文本 :param top_number: 输出词频前几 :return: [('非常', 36), ('很', 31), ('手机', 23), ('也', 18)] PS: 阅读全文
posted @ 2022-05-06 21:23 PythonNew_Mr.Wang 阅读(53) 评论(0) 推荐(0) 编辑
摘要:后端: message = {} list_f = models.Value_A.objects.all() str_list = "" for data in list_f: str_list = str_list +data.title + "," BASE_DIR = os.path.dirn 阅读全文
posted @ 2022-04-14 10:27 PythonNew_Mr.Wang 阅读(37) 评论(0) 推荐(0) 编辑
摘要:def fine_word(text_raw): """ :param text_raw: 文本 :return: 返回中文字符串 """ text = "" regStr = ".*?([\u4E00-\u9FA5]+).*?" re_text = re.findall(regStr, text_ 阅读全文
posted @ 2022-04-14 09:53 PythonNew_Mr.Wang 阅读(67) 评论(0) 推荐(0) 编辑
摘要:def find_province(city): """ :param city: "福州" :return: “福建” """ area_data = { '北京': ['北京市', '朝阳区', '海淀区', '通州区', '房山区', '丰台区', '昌平区', '大兴区', '顺义区', ' 阅读全文
posted @ 2022-04-13 09:25 PythonNew_Mr.Wang 阅读(2112) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示