kc_utils
install
pip install --upgrade kc_utils -i https://pypi.org/simple/
pip install --upgrade kc_utils['cache_redis'] -i https://pypi.org/simple/
use
time
- get_time
#:param num: 和unit配合使用计算时间
#:param sf: %Y%m%d%H%M%S
#:param unit: days = None, seconds = None, microseconds = None, milliseconds = None, minutes = None, hours = None, weeks = None
#:return: %Y%m%d%H%M%S 格式化时间
from kc_utils.time import get_time
get_time() #'20220320'
get_time(1) #'20220321'
get_time(-1) #'20220319'
get_time(-1, sf="%Y%m%d%H%M%S") #'20220319055451'
get_time(-1, sf="%Y%m%d%H%M%S", unit="hours") #'20220320045504'
- format_time
#:param log_date: 字符串日期
#:param sf: %Y%m%d%H%M%S
#:param new_sf: %Y%m%d%H%M%S
#:return: 字符串日期
from kc_utils.time import get_time, format_time
format_time(get_time()) # '2022-03-20'
cache
pip install --upgrade kc_utils['cache_redis'] -i https://pypi.org/simple/
- redis
#redis 装饰器
#:param time: ttl
## time==0 or redis_store=None, 则不走缓存;
## time > 0, 则走缓存,缓存时间为time;
## time = -1, 则走缓存,缓存时间为永久.
## time = -2, 则不走缓存,并覆盖现有缓存
#:param redis_key_prefix: redis key prefix
#:param redis_store: redis_store
from kc_utils.cache.redis_helper import redising,KcRedis
db_redis = KcRedis(host='x', port=6379, password="xxx").get_redis()
@redising(time=10, redis_key_prefix="test", redis_store=db_redis)
def func_xxx(*args, **kwargs):
return "xxx"
Metadata
Release files for kc-utils 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kc_utils-0.0.1.tar.gz | 3.7 kB | Without provenance | Details for kc_utils-0.0.1.tar.gz |
Release files / kc_utils-0.0.1.tar.gz
| Download URL | kc_utils-0.0.1.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fe8eef8bf32403842323e1c49f7883d2cd90602ebada16715a8db73d330160dc
|
|
BLAKE2b-256 checksum How to use checksums |
3db5756b719545ff8280422a54e136e88f82bcf37e5c246c14ac94c0953bc33d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.8.2 requests/2.22.0 setuptools/44.0.0.post20200106 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/2.7.18
|
Security for kc-utils 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.