Skip to main content

Installation

install as pip

pip install nest-helper==1.1.2

Usage

  • 生成 uuid

    :syntax: generate_uuid(fmt:str='-') -> int

    :param: fmt 替换的字符串

    :return: string

    >>> from pyhelper.helper import generate_uuid
    >>> print(generate_uuid())
    >>> "c294bfab-5249-4c01-8e38-02f7957afdfa"
    >>> print(generate_uuid(fmt=''))
    >>> "2204d86f2815482c83d697acd0b36c16"
    
  • 生成11位的唯一识别码

    :syntax: generate_unique_id() -> str

    :return: string

    >>> from pyhelper.helper import generate_unique_id
    >>> print(generate_unique_id())
    >>> "78LM0XLpnpv"
    
  • 生成自定义位数的随机字符串

    :syntax: generate_rnd_string(n:int=6, fmt:str='O') -> str

    :param: n 生成的字符串的位数

    :param: fmt 最终生成的字符串样式 L:全部小写; U:全部大写; N:全部数字; O: 随机字符串

    :return: string

    >>> from pyhelper.helper import generate_rnd_string
    >>> print(generate_rnd_string())
    >>> "w9y5Yk"
    >>> print(generate_rnd_string(n=10))
    >>> "T65rZduWMC"
    >>> print(generate_rnd_string(n=10, fmt="U"))
    >>> "BHDQBEAEJZ"
    
  • 生成雪花id

    :syntax: snow_flake(datacenter_id: int = 1, worker_id: int = 1, sequence: int = 0) -> int

    :param datacenter_id: 数据中心(机器区域)ID

    :param worker_id: 机器ID

    :param sequence: 序列号

    :return: int

    >>> from pyhelper.helper import snow_flake
    >>> print(snow_flake())
    >>> 1448838354849370112
    >>> print(snow_flake(1,2,0))
    >>> 1448838475976679424
    
  • url 编码

    :syntax: url_encode(url:str) -> str

    :param url: 需要编码的url

    :return: string

    >>> from pyhelper.helper import url_encode
    >>> url = "https://baidu.com?a=1&b=2"
    >>> print(url_encode(url))
    >>> "https%3A//baidu.com%3Fa%3D1%26b%3D2"
    
  • url 解码

    :syntax: url_decode(url:str) -> str

    :param url: 需要解码的url

    :return: string

    >>> from pyhelper.helper import url_decode
    >>> url = "https%3A//baidu.com%3Fa%3D1%26b%3D2"
    >>> print(url_decode(url))
    >>> "https://baidu.com?a=1&b=2"
    
  • jwt 编码

    :syntax: jwt_encode(raw: dict, secret:str, expire: int = 7200) -> str

    :param raw: 需要编码的数据

    :param secret: 密钥

    :param expire: 有效时间,默认7200秒

    :return: 返回编码后的数据

    >>> from pyhelper.helper import jwt_encode
    >>> raw = {"uid":"123456"}
    >>> print(jwt_encode(raw, secret='3ndbwa4GYr', expire=7200))
    >>> "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOiIxMjM0NTYiLCJleHAiOjE2MzQ1MTc1NDh9.Mtn-o9wtx-AsvpEXqQx8XQ_AFd7-EsRMHjGED1fcq34"
    
  • jwt 解码

    :syntax: jwt_decode(raw: str, secret: str) -> dict

    :param raw: 需要解码的数据

    :param secret: 密钥

    :return: 返回的数据

    >>> from pyhelper.helper import jwt_decode
    >>> raw = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOiIxMjM0NTYiLCJleHAiOjE2MzQ1MTc1NDh9.Mtn-o9wtx-AsvpEXqQx8XQ_AFd7-EsRMHjGED1fcq34"
    >>> print(jwt_decode(raw, secret="3ndbwa4GYr"))
    >>> {"uid":"123456"}
    

Release files for nest-helper 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nest-helper 1.1.2
File Size Uploaded
nest-helper-1.1.2.tar.gz 4.2 kB Details

Release files / nest-helper-1.1.2.tar.gz

Download URL nest-helper-1.1.2.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
f3748a067d3a69b6d6d1926d01f66d79b4584df7b199a86651cf831014e2b028
BLAKE2b-256 checksum
How to use checksums
6ecea7d21363bbda9438b078e1aba0984c25f2fc2f3cdddf637d55797926b4fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.5

Release history Release notifications | RSS feed

This release

1.1.2 This release

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page