分类:代码片段

27 篇文章

图片背景透明

``` def pic_bg_alpha(img_path): """ 图片背景透明 :param img_path: 图片地址 :return: """ from PIL import Image img = Image.open(img_path) rgba_img = img.convert(...

milvus单机版安装docker compose

``` 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函数执行时间的统计

```python def timer(func): def wrapper(*args, **kwargs): start = time.time() res = func(*args, **kwargs) print('共耗时约 {:.2f} 秒'.format(time.time() - st...