123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- # -*- coding: utf-8 -*-
- import datetime
- import uuid
- import base64
- import json
- import re
- def getUuid():
- """获取UUID
- :return: UUID字符串
- """
- return ''.join(str(uuid.uuid1()).split('-'))
- def b64Decode(b64):
- """base64解码
- :param b64: base64加密字符
- :return: 解密字符串
- """
- return base64.b64decode(b64).decode('utf-8')
- def getNowTime():
- """获取当前时间
- :return: 当前时间
- """
- return datetime.datetime.now()
- def getNowTimeStr(format="%Y%m%d%H%M%S"):
- """获取当前时间字符
- :param format: 格式化字符串,默认返回yyyyMMddHHmmss
- :return: 时间字符串
- """
- return getNowTime().strftime(format)
- def getTimeStr(time, format="%Y%m%d%H%M%S"):
- """获取当前时间字符
- :param format: 格式化字符串,默认返回yyyyMMddHHmmss
- :return: 时间字符串
- """
- return time.strftime(format)
- def toJson(jstr):
- """字符串转Json对象
- :param jstr: Json字符串
- :return: Json对象
- """
- return json.loads(jstr)
- # ———————— 正则 ————————
- def regDkh(str):
- """正则 大括号
- :param str: 字符串
- :return: 数组
- """
- p = re.compile(r"[{](.*?)[}]", re.S)
- return re.findall(p, str)
|