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

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")
发布了1560 篇原创文章 · 获赞 6061 · 访问量 1156万+

猜你喜欢

转载自blog.csdn.net/qq_41185868/article/details/103906815