utils的简介
Python Utils is a collection of small Python functions and classes which make common patterns shorter and easier. It is by no means a complete collection but it has served me quite a bit in the past and I will keep extending it.
python utils是一个小型python函数和类的集合,这些函数和类使公共模式变得更短、更容易。它绝不是一个完整的收藏,但它在过去为我服务了不少,我会继续扩展它。
文档:https://python-utils.readthedocs.io/en/latest/
utils的安装
pip install python-utils
utils的使用方法
1、基础用法
from python_utils import converters
number = converters.to_int('spam15eggs')
assert number == 15
number = converters.to_int('spam')
assert number == 0
number = converters.to_int('spam', default=1)
assert number == 1
number = converters.to_float('spam1.234')