``` def pic_bg_alpha(img_path): """ 图片背景透明 :param img_path: 图片地址 :return: """ from PIL import Image img = Image.open(img_path) rgba_img = img.convert(...
分类:代码片段
27 篇文章``` version: '3.5' services: etcd: container_name: milvus-etcd image: quay.io/coreos/etcd:v3.5.5 environment: - ETCD_AUTO_COMPACTION_MODE=revision - E...
``` def get_now_time(): """ 获取当前年月日时分秒 :return: """ now_str = time.strftime('%Y%m%d%H%M%S', time.localtime(time.time())) return now_str ```...
``` def second_to_time(second=0): """ 传入秒数,生成字幕时间 :param second: 13 :return: 00:00:13 """ # b = 61 # 10秒,如果是小数,只舍不入 hour_min_second = time.strftime('%...
``` def is_chinese(char): if '\u4e00' <= char <= '\u9fff': return True else: return False ```...
``` def get_video_duration(filename: str) -> float: """ 获取音视频的时长 :param filename: :return: """ try: result = subprocess.run(["ffprobe", "-v", "error",...
```python def timer(func): def wrapper(*args, **kwargs): start = time.time() res = func(*args, **kwargs) print('共耗时约 {:.2f} 秒'.format(time.time() - st...