一个用于格式化输出的库,主要功能包括多行输出刷新、全半角字符混合对齐、秒数及字节大小格式化等
Project description
format_print
一个用于格式化输出的库,主要功能包括多行输出刷新、全半角字符混合对齐、秒数及字节大小格式化等。
pip
pip install format_print
主要功能简介
- Unicode_len: 获取全半角混合字符串的长度
半角字符长度为1,全角字符长度为2,以此计算总长度。
- Rehuman: 数字格式化
将整数或浮点数转化为携带单位的字符串,目前包括:时长、字节,允许指定进制、单位、格式等。
- Respacing: 全半角混合字符串对齐
为同时包含全角和半角的字符串设置对齐,全角字符长度视为半角字符的2倍。
- Rows_print: 多行输出
主要用于多行字符串的刷新,可以指定输出起始行次、对齐方式
简易示例
from format_print import Unicode_len, Rehuman, Respacing, Rows_print
import time
# Unicode_len
length = Unicode_len('该文本的长度:16').get_len()
print(length) # 16
# Rehuman
print(Rehuman(100000).from_size()) # 97.66KB
print(Rehuman(500).from_seconds()) # 00h08m20s
print('\n')
# Rows_print
Rows_print(
'第1行\n这里是第2行',
'^',
).print_str()
'''
第1行
这里是第2行
'''
# Respacing
for i in range(37):
print(
Respacing(
"[",
("=" * min(i, 12), 12, "<"),
"进度:{:>3.2f}%".format(i / 36 * 100),
("=" * (i - 24), 12, "<"),
"]",
space = '_'
).get_str(),
end = '\r'
)
time.sleep(0.3)
print()
'''
生成进度条
[============进度:50.00%____________]
'''
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
format_print-1.0.tar.gz
(4.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file format_print-1.0.tar.gz.
File metadata
- Download URL: format_print-1.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da4867840b12b910160f6df7009ccc28479ad37d1d73d2430eb34c1e541a55cc
|
|
| MD5 |
bf1f34cd801cc520795bb3a1b117b719
|
|
| BLAKE2b-256 |
bc23ae6fc135883e8be1868e47c3aca84682b2ea9d7924371c5bdaca90089983
|
File details
Details for the file format_print-1.0-py3-none-any.whl.
File metadata
- Download URL: format_print-1.0-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4aa441f206fef284b6d78726cc8a878fd9b0e9f37ea88f37be35efafab974a20
|
|
| MD5 |
b09e890149289c1cb45122974b0d9385
|
|
| BLAKE2b-256 |
87529693d33ffaf4ff5e58b151d5b23251b49ec9e445af436803e9e16858cde0
|