安全输入工具库,支持彩色输出,KeyboardInterrupt保护等
Project description
Code_Tools
介绍:
一个给初学者制作的 Python 工具库, 基于 Python 3.14.4 制作
安装
pip install luci-code-tools
可用内容
color()
参数包括 text_color (选择颜色,使用ANSI序列码), mode (显示方式,常用的是"1",如果不需要显示方式, 使用默认方式可以输入"0"), IsEnter 默认是 True , 也就是多换一行, 你可以更换设置为False让输出没有多余换行, 函数参数最后面可以增加end, sep等操作
可以不填 text_color 和 mode 参数, 如果不填将使用默认
clear_screen()
直接输入这个函数名就可以让代码检测你的系统并使用对应的清屏命令
例如:
"win32" = Windows
else = macOS,Linux
对应代码为:
from sys import platform, exit
from subprocess import run
if platform == "win32" # <- win32 == Windows
run("cls", shell=True)
else: # <- 包括 macOS 和 Linux
run("clear", shell=True)
safe_input()
safe_int()
safe_float()
除了 safe_input 以外都包括 ValueError 处理, 因为 input 不可能触发 ValueError
3个函数包括的参数有: prompt, text_color, mode
prompt 是用户输入提示
text_color 是用户提示的颜色,就像 color 函数中的 text_color 一样
mode 也是 color 中的意思, 不过这次如果 color 和 mode 参数不写就会使用默认参数 ( 37 白色和 0 默认 )
示例 ("[space]"代表空行, "{mode}"代表输出格式)
color("Hello", 32, 1)
Hello {绿色;粗体}
color("Hello", 32, 1, IsEnter=False)
Hello {绿色;粗体}
其他
ANSI常用序列 提示: 90-97 为亮色前景色,100-107 为亮色背景色
| 前景色 | 效果 |
|---|---|
| 30 | 黑色 |
| 31 | 红色 |
| 32 | 绿色 |
| 33 | 黄色 |
| 34 | 蓝色 |
| 35 | 紫色 |
| 36 | 青色 |
| 37 | 白色 |
| 显示方式 | 效果 |
|---|---|
| 0 | 默认 |
| 1 | 粗体 + 高亮 |
| 2 | 暗淡 |
| 3 | 斜体(部分终端不支持) |
| 4 | 下划线 |
| 5 | 闪烁 |
| 6 | 快闪(部分终端不支持) |
| 7 | 反色(前景色与背景色互换) |
| 8 | 隐藏 |
| 9 | 删除线 |
| 背景色 | 效果 |
|---|---|
| 40 | 黑色 |
| 41 | 红色 |
| 42 | 绿色 |
| 43 | 黄色 |
| 44 | 蓝色 |
| 45 | 紫色 |
| 46 | 青色 |
| 47 | 白色 |
制作者 & 感谢名单
| 作者 | 分工 |
|---|---|
| Luci_Code | 代码 |
| Luci_Code | 文档 |
| Luci_Code | 思路 |
| Luci_Code | 上传 |
| DeepSeek | 检查 |
感谢
<感谢您的阅读,我是Luci_Code, 一名2014年出生的开发者 >
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
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 luci_code_tools-1.0.0.tar.gz.
File metadata
- Download URL: luci_code_tools-1.0.0.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be3035025497bb74ef50f2ef58b737fa142256539debb690e1fbc0db067db614
|
|
| MD5 |
ce2c57ff2567fabe678010188f554592
|
|
| BLAKE2b-256 |
bc2fcebb085ad616ce35592822a1c248edc4221847613b281b3513b28fe674d8
|
File details
Details for the file luci_code_tools-1.0.0-py3-none-any.whl.
File metadata
- Download URL: luci_code_tools-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9e33ee23e1298a882ffa2a62fec46a4a1da63f2df779c711615d2c86d1fffb1
|
|
| MD5 |
a1b77b6f85178cf68d95ca9a90c8efd9
|
|
| BLAKE2b-256 |
25296947ff26aa77fb03bc457255d6a7fa509f383a75dc6eb74398c5ce59cad1
|