zl程序教程

您现在的位置是:首页 >  后端

当前栏目

Py之utils:utils库的简介、安装、使用方法之详细攻略

安装方法 详细 简介 攻略 py utils 使用
2023-09-14 09:04:48 时间

Py之utils:utils库的简介、安装、使用方法之详细攻略

 

 

 

目录

utils库的简介

utils库的安装

utils库的使用方法

1、基础用法


 

 

 

 

utils库的简介

          有时你会一遍又一遍地写一个函数;有时你会抬头看天花板,问“为什么,Guido,为什么标准库不包括这个?”“嗯,我们也许不能回答这个问题。但是我们可以把这些功能集中到一个地方!

 

 

utils库的安装

pip install utils

 

utils库的使用方法

1、基础用法

from utils import enum

class Colors(enum.Enum):
    RED = 0
    GREEN = 1

    # Defining an Enum class allows you to specify a few
    # things about the way it's going to behave.
    class Options:
        frozen = True # can't change attributes
        strict = True # can only compare to itself; i.e., Colors.RED == Animals.COW
                      # will raise an exception.

# or use the enum factory (no Options, though)
ColorsAlso = enum.enum("RED", "GREEN")