Metadata-Version: 2.4
Name: Luci-Code-Tools
Version: 1.2.3
Summary: 安全输入工具库,支持彩色输出,KeyboardInterrupt保护等
Home-page: https://github.com/Luci-Codeing/code_tools
Author: Luci_Code
Author-email: 3967742419@qq.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENCE
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python
Dynamic: summary

[![PyPI version](https://badge.fury.io/py/luci-code-tools.svg)](https://pypi.org/project/luci-code-tools/)

# Luci_Code_Tools

## 介绍:

给初学者制作的 *Python* 工具库, 基于 Python 3.13.3 制作

### 安装 & 导入

```bash
pip install Luci-Code-Tools
```

```python
from Luci_code_tools import *
# 或者
import Luci_code_tools
```

#  内容

**函数**

**safe_\*** = **safe_input, safe_int, safe_float**

| 名称 | 作用 | 参数 |
| --- | --- | --- |
| color | 输出ANSI彩色字符 | data, text_color, bg_color, mode, newline |
| color_rgb | 输出RGB彩色字符 | data, r, g, b, mode, newline |
| clear_screen | 可跨平台的清屏 | None (没有参数) |
| safe_* | 安全的输入, 防止Ctrl + C和输入流关闭等报错 | prompt, text_color, bg_color, mode |
| cloudflare_play | 输出 CloudFlare 人机验证 | None (没有参数) |

**提示**: ***参数需要按照顺序填***

---

# 用法

---

```python
color()
```
**color** 函数有 5 个参数, 你可以选填

**1.data**, data 参数就仅仅是输出的内容而已

**2.text_color**, text_color 参数可以让输入有颜色, 参数表见**其他**部分段

**3.bg_color**, bg_color 全称 background_color, 用于管理输出的背景颜色

**4.mode**, mode 参数用于管理输出的格式, 参数表见**其他**部分段

**5.newline**, newline 参数只有 True 和 False, 默认为 True, 测试:

```python
""" newline 参数测试 """

# newline = False

"""
输出内容-1
输出内容-2
输入: a
if 跳转的输出
"""

# newline = True

"""
输出内容-1

输出内容-2

输入:a

if 跳转的输出
"""

# newline 让输出变得更加美观, 可分辨
```

---

```python
color_rgb()
```

**color_rgb** 有 5 个参数, 分别是data, r, g, b, newline

**newline 和 data** 的用法和之前的一样, 这里不过多赘述

**r, g, b**, r, g, b 参数使用 RGB 标准显示彩色, r, g, b 是字面意思, 让你填入 rgb 值, 按顺序填

---

```python
clear_screen()
```

**clear_screen源码**

```python
def clear_screen() -> None:
    """ 跨平台兼容清屏 """
    if platform == "win32":
        run(['cmd', '/c', 'cls'])
    else:
        run(['clear'])
```

**clear_screen** 可以直接使用, 无需参数, 自动适配平台并运行相应的 *清屏命令*

清屏命令:

```python
""" Windows系统: **cls**, MacOS / Linux: **clear** """
```

---

```python
safe_input, safe_int, safe_float
```

这三条命令我会逐条讲解:

- safe_input

顾名思义: 安全的输入字符, 用处为防止用户 Ctrl + C 和 输入流停止 而造成的报错

用法: prompt, text_color, bg_color, mode

此处的 **text_color, bg_color, mode** 的用法和之前的 color 函数没有区别, **prompt** 就相当于 **data**

- safe_int / safe_float

由于这两条命令的用法相同我就放在一起讲了

参数: 和 safe_input 的相同

作用: 既然是输入数字我们就要防止用户输入字符, 不然会触发 **ValueError**, 所以代码中有 try - except **ValueError, KeyboardInterrupt, EOFError** 的防范, ValueError 输入错误会重新输入, **KeyboardInterrupt / EOFError** 就和之前一样

---

- cloudflare_play

这个函数用着玩的, 无参数, 运行输出:
┏━━━━━━━━━━━━━━┓
┃ ┌┐ 请验证您是真人   ☁️           ┃
┃ └┘                          cloudflare     ┃
┗━━━━━━━━━━━━━━┛

---

# 其他

**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 | 白色 |

---

# 制作者 & 感谢名单

| 作者 | 分工 |
| --- | --- |
| DeepSeek | 检查 |
| DeepSeek | 改进 |
| Luci_Code | 代码 |
| Luci_Code | 文档 |
| Luci_Code | 思路 |
| Luci_Code | 上传 |

---

# 感谢

***<感谢您的阅读，我是Luci_Code， 一名2014年出生的开发者 >***
