Luci-Code-Tools 2.1.6__tar.gz → 2.2.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- luci_code_tools-2.2.6/Luci_Code_Tools.egg-info/PKG-INFO +1075 -0
- {luci_code_tools-2.1.6 → luci_code_tools-2.2.6}/Luci_Code_Tools.egg-info/SOURCES.txt +1 -1
- {luci_code_tools-2.1.6 → luci_code_tools-2.2.6}/Luci_Code_Tools.egg-info/dependency_links.txt +0 -0
- {luci_code_tools-2.1.6 → luci_code_tools-2.2.6}/Luci_Code_Tools.egg-info/top_level.txt +0 -0
- {luci_code_tools-2.1.6 → luci_code_tools-2.2.6}/Luci_code_tools.py +8 -8
- luci_code_tools-2.2.6/PKG-INFO +1075 -0
- luci_code_tools-2.2.6/README.md +1053 -0
- {luci_code_tools-2.1.6 → luci_code_tools-2.2.6}/setup.cfg +0 -0
- {luci_code_tools-2.1.6 → luci_code_tools-2.2.6}/setup.py +1 -1
- luci_code_tools-2.1.6/Luci_Code_Tools.egg-info/PKG-INFO +0 -541
- luci_code_tools-2.1.6/PKG-INFO +0 -541
- luci_code_tools-2.1.6/README.md +0 -519
- /luci_code_tools-2.1.6/LICENCE → /luci_code_tools-2.2.6/LICENSE +0 -0
|
@@ -0,0 +1,1075 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: Luci-Code-Tools
|
|
3
|
+
Version: 2.2.6
|
|
4
|
+
Summary: 一个简单的工具库 / A Eazy Tools Module
|
|
5
|
+
Home-page: https://github.com/Luci-Code-2014
|
|
6
|
+
Author: Luci_Code
|
|
7
|
+
Author-email: 3967742419@qq.com
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Requires-Python: >=3.6
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Dynamic: author
|
|
14
|
+
Dynamic: author-email
|
|
15
|
+
Dynamic: classifier
|
|
16
|
+
Dynamic: description
|
|
17
|
+
Dynamic: description-content-type
|
|
18
|
+
Dynamic: home-page
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
Dynamic: requires-python
|
|
21
|
+
Dynamic: summary
|
|
22
|
+
|
|
23
|
+
[](https://pypi.org/project/Luci_Code_Tools/)
|
|
24
|
+
|
|
25
|
+
[]()
|
|
26
|
+
|
|
27
|
+
[]()
|
|
28
|
+
|
|
29
|
+
[]()
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
# 中文文档
|
|
34
|
+
|
|
35
|
+
**Chinese Document**
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
**English Document use DeepSeek AI and Google Translate**
|
|
40
|
+
|
|
41
|
+
**There may be some inaccuracies**
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
# 欢迎 💎
|
|
46
|
+
|
|
47
|
+
**感谢你点击这个项目**
|
|
48
|
+
|
|
49
|
+
**这是一个 *工具箱 / 快捷工具* 类型的项目**
|
|
50
|
+
|
|
51
|
+
**带有 *6* 个函数可使用**
|
|
52
|
+
|
|
53
|
+
# Luci_Code_Tools 🔍
|
|
54
|
+
|
|
55
|
+
**代码花费 *9000+* 字符数**
|
|
56
|
+
|
|
57
|
+
***2026 年 5 月 9 日*开始维护**
|
|
58
|
+
|
|
59
|
+
*27* 个异常处理, 个个定制的异常返回 **(触发异常时返回的操作)**
|
|
60
|
+
|
|
61
|
+
# 许可证 📄
|
|
62
|
+
|
|
63
|
+
使用 **MIT License** 许可证
|
|
64
|
+
|
|
65
|
+
# 设备 📱 💻
|
|
66
|
+
|
|
67
|
+
早期版本 (**2.1.5** 及更早) 使用 *Android* 上的 ***MT 管理器*** (软件开发者: **Bin**)
|
|
68
|
+
|
|
69
|
+
早期版本以后的版本使用 (**版本 >=2.1.6**) ***Visual Studio Code*** 进行编写 (软件开发商: **Microsoft Corporation**)
|
|
70
|
+
|
|
71
|
+
## 设备信息
|
|
72
|
+
|
|
73
|
+
Android 设备信息: Android 13
|
|
74
|
+
|
|
75
|
+
Windows 设备信息: Windows 10 22H2
|
|
76
|
+
|
|
77
|
+
# 作者 ヾ(≧▽≦*)o
|
|
78
|
+
|
|
79
|
+
作者名字叫: **Luci_Code**
|
|
80
|
+
|
|
81
|
+
**2014** 年出生 🐱
|
|
82
|
+
|
|
83
|
+
此代码的编写者 : Luci_Code
|
|
84
|
+
|
|
85
|
+
此文档的编写者 : Luci_Code
|
|
86
|
+
|
|
87
|
+
Github 链接: **https://github.com/Luci-Code-2014/**
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
# 代码介绍 🎮
|
|
92
|
+
|
|
93
|
+
项目文件夹 📂:
|
|
94
|
+
|
|
95
|
+
Luci_code_tools.py | 代码主文件
|
|
96
|
+
|
|
97
|
+
200+ 行数运行的代码文件 🐱
|
|
98
|
+
|
|
99
|
+
setup.py | 上传信息
|
|
100
|
+
|
|
101
|
+
在 PyPI 上上传时传输的信息
|
|
102
|
+
|
|
103
|
+
包括 适用版本, 许可证信息等
|
|
104
|
+
|
|
105
|
+
你可以在此模块的网页界面左边部分看到他给予的信息喵🐱
|
|
106
|
+
|
|
107
|
+
README.md | 此文档
|
|
108
|
+
|
|
109
|
+
这就是你现在看到的文档喵🐱
|
|
110
|
+
|
|
111
|
+
LICENSE | 许可证 (MIT)
|
|
112
|
+
|
|
113
|
+
*MIT* 许可证是 目前 **(2026 年)** 最自由的许可证
|
|
114
|
+
|
|
115
|
+
他不要求你获得授权
|
|
116
|
+
|
|
117
|
+
他只要求在转载时能加一个来源喵🐱
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
## 主代码
|
|
121
|
+
|
|
122
|
+
**27** 个异常处理
|
|
123
|
+
|
|
124
|
+
包括:
|
|
125
|
+
|
|
126
|
+
*结果* 板块为代码中给出的结果
|
|
127
|
+
|
|
128
|
+
在原本的代码中所有**异常处理**的结果都为报错
|
|
129
|
+
|
|
130
|
+
**错误退出**是指在错误的状态的报出错误并退出
|
|
131
|
+
|
|
132
|
+
比如程序被不正确的方式报错了, 这时候就应该*错误退出*程序, 会被 SystemExit 捕获
|
|
133
|
+
|
|
134
|
+
| 报错 | 意思 | 结果 |
|
|
135
|
+
| --- | --- | --- |
|
|
136
|
+
| ValueError | 输入的值与期待的值类型错误 | 重试 |
|
|
137
|
+
| KeyboardInterrupt | 在 Ctrl + C 时, 命令行会被中断而显示的报错 | 退出 + 提示语 |
|
|
138
|
+
| EOFError | 意思是 End of file , 代表输入流被关闭 | 退出 + 提示语 |
|
|
139
|
+
| MemoryError | 内存过高导致的错误, 比如你输入了一个极高长度的字符超过了你的内存大小 | 退出(错误退出) + 提示语 |
|
|
140
|
+
| SystemError | Python 解释器损坏 | 退出 + 提示语 |
|
|
141
|
+
| OSError | 你系统炸了 😂 (可能是系统文件损坏问题引起的错误) | 退出(错误退出) + 提示语 |
|
|
142
|
+
|
|
143
|
+
等错误, 总共有 **27** 种异常处理, 正常情况下 ***几乎不可能报错***
|
|
144
|
+
|
|
145
|
+
# 📦 安装方式 & 导入方式
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
pip install Luci-Code-Tools
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
默认会安装最新版
|
|
152
|
+
|
|
153
|
+
你可以通过把
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
pip install <包名>
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
改成
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
pip install <包名>==<版本号>
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
来安装对应的版本
|
|
166
|
+
|
|
167
|
+
## 导入 & 引用
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
|
|
171
|
+
# 注: 所有方式的示例函数为 color 函数
|
|
172
|
+
|
|
173
|
+
# 导入
|
|
174
|
+
import Luci_code_tools
|
|
175
|
+
Luci_code_tools.color("HelloWorld", 32, None, 1, 2)
|
|
176
|
+
|
|
177
|
+
# 导入 + as
|
|
178
|
+
import Luci_code_tools as lct
|
|
179
|
+
lct.color("HelloWorld", 32, None, 1, 2)
|
|
180
|
+
|
|
181
|
+
# 引用
|
|
182
|
+
from Luci_code_tools import color
|
|
183
|
+
color("HelloWorld", 32, None, 1, 2)
|
|
184
|
+
|
|
185
|
+
# 引用 + as
|
|
186
|
+
from Luci_code_tools import color as cl
|
|
187
|
+
cl("HelloWorld", 32, None, 1, 2)
|
|
188
|
+
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
# 参数介绍
|
|
194
|
+
|
|
195
|
+
line 的输出样式是
|
|
196
|
+
|
|
197
|
+
{
|
|
198
|
+
|
|
199
|
+
"line": 0,
|
|
200
|
+
|
|
201
|
+
"data": "Hello",
|
|
202
|
+
|
|
203
|
+
"data": "World",
|
|
204
|
+
|
|
205
|
+
"output": 2
|
|
206
|
+
|
|
207
|
+
} "output": 2 等于两个输出函数
|
|
208
|
+
|
|
209
|
+
输出效果:
|
|
210
|
+
|
|
211
|
+
HelloWorld ("Hello" 和 "World" 是两个字符串)
|
|
212
|
+
|
|
213
|
+
{
|
|
214
|
+
|
|
215
|
+
"line": 1,
|
|
216
|
+
|
|
217
|
+
"data": "Hello",
|
|
218
|
+
|
|
219
|
+
"data": "World",
|
|
220
|
+
|
|
221
|
+
"output": 2
|
|
222
|
+
|
|
223
|
+
} "output": 2 等于两个输出函数
|
|
224
|
+
|
|
225
|
+
输出效果:
|
|
226
|
+
|
|
227
|
+
Hello
|
|
228
|
+
|
|
229
|
+
(这里的空间其实不空行)
|
|
230
|
+
|
|
231
|
+
World
|
|
232
|
+
|
|
233
|
+
{
|
|
234
|
+
|
|
235
|
+
"line": 2,
|
|
236
|
+
|
|
237
|
+
"data": "Hello",
|
|
238
|
+
|
|
239
|
+
"data": "World",
|
|
240
|
+
|
|
241
|
+
"output": 2
|
|
242
|
+
|
|
243
|
+
} "output": 2 等于两个输出函数
|
|
244
|
+
|
|
245
|
+
输出效果:
|
|
246
|
+
|
|
247
|
+
Hello
|
|
248
|
+
|
|
249
|
+
(Markdown 格式限制, 中间其实有空着一行)
|
|
250
|
+
|
|
251
|
+
World
|
|
252
|
+
|
|
253
|
+
line 参数可以调更高, 但是由于篇幅限制我需要减少测试喵🐱
|
|
254
|
+
|
|
255
|
+
通过数字个性化调整空行数来提高辨识度
|
|
256
|
+
|
|
257
|
+
## 函数参数
|
|
258
|
+
|
|
259
|
+
我们先列出目前代码中所用的函数
|
|
260
|
+
|
|
261
|
+
## 函数
|
|
262
|
+
|
|
263
|
+
- color_rgb
|
|
264
|
+
|
|
265
|
+
- color
|
|
266
|
+
|
|
267
|
+
- clear_screen
|
|
268
|
+
|
|
269
|
+
- safe_input
|
|
270
|
+
|
|
271
|
+
- safe_int
|
|
272
|
+
|
|
273
|
+
- safe_float
|
|
274
|
+
|
|
275
|
+
## 所有参数
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
我们首先介绍 **color_rgb**
|
|
280
|
+
|
|
281
|
+
- color_rgb
|
|
282
|
+
|
|
283
|
+
这个函数是一个管理 RGB 彩色输出的函数, 使用 **ANSI 转义序列 + 参数** 完成的构建
|
|
284
|
+
|
|
285
|
+
参数包括:
|
|
286
|
+
|
|
287
|
+
data r g b mode line
|
|
288
|
+
|
|
289
|
+
- data
|
|
290
|
+
|
|
291
|
+
data 参数是控制 **输入的内容** 的参数
|
|
292
|
+
|
|
293
|
+
- r
|
|
294
|
+
|
|
295
|
+
- g
|
|
296
|
+
|
|
297
|
+
- b
|
|
298
|
+
|
|
299
|
+
这三个参数按照 R, G, B 三个字符的顺序写, 比如 255, 0, 0 为**纯红色**
|
|
300
|
+
|
|
301
|
+
- mode
|
|
302
|
+
|
|
303
|
+
mode 参数是控制输出模式的参数, 具体输出模式参数表在最后
|
|
304
|
+
|
|
305
|
+
- line
|
|
306
|
+
|
|
307
|
+
line 参数输入整数, 具体信息在 **"参数介绍"** 部分片段
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
- color
|
|
312
|
+
|
|
313
|
+
此函数是一个管理 ANSI 转义序列彩色字符的函数 🤔
|
|
314
|
+
|
|
315
|
+
- data
|
|
316
|
+
|
|
317
|
+
管理在彩色字符输出时输出的字符串
|
|
318
|
+
|
|
319
|
+
- text_color
|
|
320
|
+
|
|
321
|
+
通过 ANSI 颜色码来控制输出的颜色, 不用调来调去, 详细参数在最后的参数表
|
|
322
|
+
|
|
323
|
+
- bg_color
|
|
324
|
+
|
|
325
|
+
通过 ANSI 颜色码来控制输出时背景的颜色, 详细参数在最后的参数表
|
|
326
|
+
|
|
327
|
+
- mode
|
|
328
|
+
|
|
329
|
+
通过 ANSI 转义序列的输出方式来控制输出 / 显示的方式
|
|
330
|
+
|
|
331
|
+
- line
|
|
332
|
+
|
|
333
|
+
和上一位 color_rgb 是一个意思, 都可以控制输出时间隔的行数
|
|
334
|
+
|
|
335
|
+
---
|
|
336
|
+
|
|
337
|
+
- clear_screen
|
|
338
|
+
|
|
339
|
+
clear_screen 没有参数, 但是我带来了函数介绍
|
|
340
|
+
|
|
341
|
+
**函数介绍**
|
|
342
|
+
|
|
343
|
+
此函数有:
|
|
344
|
+
|
|
345
|
+
> 判断系统自动使用相对应清屏命令
|
|
346
|
+
|
|
347
|
+
比如:
|
|
348
|
+
|
|
349
|
+
Android -> clear (Linux 内核)
|
|
350
|
+
|
|
351
|
+
Linux -> clear
|
|
352
|
+
|
|
353
|
+
Windows -> cls
|
|
354
|
+
|
|
355
|
+
来切换使用的清屏命令
|
|
356
|
+
|
|
357
|
+
> 绝对的防注入, 列表控制清屏的参数与命令
|
|
358
|
+
|
|
359
|
+
> 即使是没有命令行的环境 (无法使用 clear / cls 命令的环境) 也可以使用 shutil 模块来检测终端高度并输出对应的空行数
|
|
360
|
+
|
|
361
|
+
> 甚至不能获取到终端高度也能输出 250 个空行来 "清屏"
|
|
362
|
+
|
|
363
|
+
---
|
|
364
|
+
|
|
365
|
+
- safe_input
|
|
366
|
+
|
|
367
|
+
- safe_int
|
|
368
|
+
|
|
369
|
+
- safe_float
|
|
370
|
+
|
|
371
|
+
这些 **safe_\*** 的参数都是一样的:
|
|
372
|
+
|
|
373
|
+
prompt | 提示词
|
|
374
|
+
|
|
375
|
+
text_color | 提示词颜色
|
|
376
|
+
|
|
377
|
+
bg_color | 提示词背景颜色
|
|
378
|
+
|
|
379
|
+
mode | 提示词输出方式
|
|
380
|
+
|
|
381
|
+
- prompt
|
|
382
|
+
|
|
383
|
+
prompt 跟 data 参数是一个意思喵🐱
|
|
384
|
+
|
|
385
|
+
- text_color
|
|
386
|
+
|
|
387
|
+
- bg_color
|
|
388
|
+
|
|
389
|
+
- mode
|
|
390
|
+
|
|
391
|
+
这三个参数和 color, color_rgb 中的这三个参数是一样的, 代表的意思相同喵🐱
|
|
392
|
+
|
|
393
|
+
---
|
|
394
|
+
|
|
395
|
+
# 参数表
|
|
396
|
+
|
|
397
|
+
## 前景色
|
|
398
|
+
|
|
399
|
+
| 前景色 - 值 | 效果 |
|
|
400
|
+
| --- | --- |
|
|
401
|
+
| 30 | 黑色 |
|
|
402
|
+
| 31 | 红色 |
|
|
403
|
+
| 32 | 绿色 |
|
|
404
|
+
| 33 | 黄色 |
|
|
405
|
+
| 34 | 蓝色 |
|
|
406
|
+
| 35 | 紫色 |
|
|
407
|
+
| 36 | 青色 |
|
|
408
|
+
| 37 | 白色 |
|
|
409
|
+
|
|
410
|
+
## 前景色 - 浅色
|
|
411
|
+
|
|
412
|
+
| 前景色 - 值 | 效果 |
|
|
413
|
+
| --- | --- |
|
|
414
|
+
| 90 | 深灰色 |
|
|
415
|
+
| 91 | 浅红色 |
|
|
416
|
+
| 92 | 浅绿色 |
|
|
417
|
+
| 93 | 浅黄色 |
|
|
418
|
+
| 94 | 浅蓝色 |
|
|
419
|
+
| 95 | 浅紫色 |
|
|
420
|
+
| 96 | 浅青色 |
|
|
421
|
+
| 97 | 浅灰色 |
|
|
422
|
+
|
|
423
|
+
## 背景色
|
|
424
|
+
|
|
425
|
+
| 背景色 - 值 | 效果 |
|
|
426
|
+
| --- | --- |
|
|
427
|
+
| 40 | 黑色 |
|
|
428
|
+
| 41 | 红色 |
|
|
429
|
+
| 42 | 绿色 |
|
|
430
|
+
| 43 | 黄色 |
|
|
431
|
+
| 44 | 蓝色 |
|
|
432
|
+
| 45 | 紫色 |
|
|
433
|
+
| 46 | 青色 |
|
|
434
|
+
| 47 | 白色 |
|
|
435
|
+
|
|
436
|
+
## 背景色 - 浅色
|
|
437
|
+
|
|
438
|
+
| 背景色 - 值 | 效果 |
|
|
439
|
+
| --- | --- |
|
|
440
|
+
| 100 | 深灰色 |
|
|
441
|
+
| 101 | 浅红色 |
|
|
442
|
+
| 102 | 浅绿色 |
|
|
443
|
+
| 103 | 浅黄色 |
|
|
444
|
+
| 104 | 浅蓝色 |
|
|
445
|
+
| 105 | 浅紫色 |
|
|
446
|
+
| 106 | 浅青色 |
|
|
447
|
+
| 107 | 纯白色 |
|
|
448
|
+
|
|
449
|
+
## 输出方式
|
|
450
|
+
|
|
451
|
+
| 显示方式 - 值 | 效果 |
|
|
452
|
+
| --- | --- |
|
|
453
|
+
| 0 | 默认 |
|
|
454
|
+
| 1 | 高亮 + 加粗 |
|
|
455
|
+
| 2 | 暗淡 |
|
|
456
|
+
| 3 | 斜体 (部分终端可能不支持) |
|
|
457
|
+
| 4 | 下划线 |
|
|
458
|
+
| 5 | 闪烁 |
|
|
459
|
+
| 6 | 快闪(部分终端可能不支持) |
|
|
460
|
+
| 7 | 反色(前景色与背景色互换) |
|
|
461
|
+
| 8 | 隐藏 |
|
|
462
|
+
| 9 | 删除线 |
|
|
463
|
+
|
|
464
|
+
---
|
|
465
|
+
|
|
466
|
+
# 制作人员 & 感谢名单 (以贡献程度排名从上到下)
|
|
467
|
+
|
|
468
|
+
| 人员 | 提供 |
|
|
469
|
+
| DeepSeek | 构建 & 打包 & 上传教程 |
|
|
470
|
+
| DeepSeek | 提供改进意见 |
|
|
471
|
+
| DeepSeek | 环境帮助 |
|
|
472
|
+
| Luci_Code | 编写 |
|
|
473
|
+
| Luci_Code | 打包 |
|
|
474
|
+
| Luci_Code | 制作 |
|
|
475
|
+
| Luci_Code | 构建 |
|
|
476
|
+
| Luci_Code | 上传 |
|
|
477
|
+
| Luci_Code | 构思 |
|
|
478
|
+
|
|
479
|
+
---
|
|
480
|
+
|
|
481
|
+
# 快速上手
|
|
482
|
+
|
|
483
|
+
## 输入输出
|
|
484
|
+
|
|
485
|
+
```python
|
|
486
|
+
from Luci_code_tools import color, safe_input
|
|
487
|
+
|
|
488
|
+
text = safe_input("请输入文本: ", 32, None, 1)
|
|
489
|
+
color(f"你输入了 {text}", 32, None, 1, 2)
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
## 计算器
|
|
493
|
+
|
|
494
|
+
```python
|
|
495
|
+
from Luci_code_tools import color, safe_float, safe_input
|
|
496
|
+
from sys import exit
|
|
497
|
+
|
|
498
|
+
color("=== 计算器 ===", 32, None, 1, 2)
|
|
499
|
+
while True:
|
|
500
|
+
num1 = safe_float("请输入第一位数字: ", 32, None, 1)
|
|
501
|
+
num2 = safe_float("请输入第一位数字: ", 32, None, 1)
|
|
502
|
+
operators = safe_input("请输入运算符(+, -, *, /, 输入 quit 退出): ")
|
|
503
|
+
if operators == "+":
|
|
504
|
+
color(f"结果为: {num1 + num2}\n==========", 32, None, 1, 2)
|
|
505
|
+
continue
|
|
506
|
+
elif operators == "-":
|
|
507
|
+
color(f"结果为: {num1 - num2}\n==========", 32, None, 1, 2)
|
|
508
|
+
continue
|
|
509
|
+
elif operators == "*":
|
|
510
|
+
color(f"结果为: {num1 * num2}\n==========", 32, None, 1, 2)
|
|
511
|
+
continue
|
|
512
|
+
elif operators == "/":
|
|
513
|
+
if num2 == 0:
|
|
514
|
+
color("除数不能等于 0\n==========", 33, None, 1, 2)
|
|
515
|
+
continue
|
|
516
|
+
else:
|
|
517
|
+
color(f"结果为: {num1 / num2}\n==========", 32, None, 1, 2)
|
|
518
|
+
continue
|
|
519
|
+
elif operators == "quit":
|
|
520
|
+
color("=== 退出成功 ===", 32, None, 1, 2)
|
|
521
|
+
exit(0)
|
|
522
|
+
else:
|
|
523
|
+
color("没有这个运算符!\n==========", 33, None, 1, 2)
|
|
524
|
+
continue
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
## 文件读写
|
|
528
|
+
|
|
529
|
+
```python
|
|
530
|
+
from Luci_code_tools import color
|
|
531
|
+
from os import remove
|
|
532
|
+
from json import load, dump, JSONDecodeError
|
|
533
|
+
|
|
534
|
+
JSON = {
|
|
535
|
+
"test": "This is Test content",
|
|
536
|
+
"test2": "This is Test content 2"
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
FILE_PATH = "user.json"
|
|
540
|
+
|
|
541
|
+
def fix_json(prompt: str) -> None:
|
|
542
|
+
color(prompt, 33, None, 1, 2)
|
|
543
|
+
with open(FILE_PATH, "w", encoding="utf-8") as f:
|
|
544
|
+
dump(JSON, f, ensure_ascii=False, indent=4, sort_keys=True)
|
|
545
|
+
color("修复成功! 请重启程序", 32, None, 1)
|
|
546
|
+
|
|
547
|
+
try:
|
|
548
|
+
with open(FILE_PATH, "r", encoding="utf-8") as f:
|
|
549
|
+
data = load(f)
|
|
550
|
+
except FileNotFoundError:
|
|
551
|
+
fix_json("文件不存在, 正在修复中...")
|
|
552
|
+
except JSONDecodeError:
|
|
553
|
+
fix_json("Json 文件格式或内容错误")
|
|
554
|
+
else:
|
|
555
|
+
content_1 = data["test"]
|
|
556
|
+
content_2 = data["test2"]
|
|
557
|
+
color(f"内容1: {content_1}\n内容2: {content_2}\n\n测试成功!", 32, None, 1, 2)
|
|
558
|
+
remove(FILE_PATH)
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
---
|
|
562
|
+
|
|
563
|
+
# English Document
|
|
564
|
+
|
|
565
|
+
**英语文档**
|
|
566
|
+
|
|
567
|
+
---
|
|
568
|
+
|
|
569
|
+
# Welcome 💎
|
|
570
|
+
|
|
571
|
+
**Thanks for checking out this project**
|
|
572
|
+
|
|
573
|
+
**This is a *toolbox / quick-utility* style project**
|
|
574
|
+
|
|
575
|
+
**Features *6* functions for use**
|
|
576
|
+
|
|
577
|
+
# Luci_Code_Tools 🔍
|
|
578
|
+
|
|
579
|
+
**Codebase spans over *9,000* characters**
|
|
580
|
+
|
|
581
|
+
**Maintenance began on *May 9, 2026***
|
|
582
|
+
|
|
583
|
+
*27* exception handlers, each with a custom return value **(the output returned when an exception is triggered)**
|
|
584
|
+
|
|
585
|
+
# License 📄
|
|
586
|
+
|
|
587
|
+
Uses the **MIT License**
|
|
588
|
+
|
|
589
|
+
# Devices 📱 💻
|
|
590
|
+
|
|
591
|
+
Early versions (**2.1.5** and earlier) were developed using ***MT Manager*** on *Android* (Developer: **Bin**)
|
|
592
|
+
|
|
593
|
+
Versions from **2.1.6** onwards were written using ***Visual Studio Code*** (Developer: **Microsoft Corporation**)
|
|
594
|
+
|
|
595
|
+
## Device Information
|
|
596
|
+
|
|
597
|
+
Android device info: Android 13
|
|
598
|
+
|
|
599
|
+
Windows device info: Windows 10 22H2
|
|
600
|
+
|
|
601
|
+
# Author ヾ(≧▽≦*)o
|
|
602
|
+
|
|
603
|
+
Author's name: **Luci_Code**
|
|
604
|
+
|
|
605
|
+
Born in **2014** 🐱
|
|
606
|
+
|
|
607
|
+
Code written by: Luci_Code
|
|
608
|
+
|
|
609
|
+
Documentation written by: Luci_Code
|
|
610
|
+
|
|
611
|
+
GitHub link: **https://github.com/Luci-Code-2014/**
|
|
612
|
+
|
|
613
|
+
---
|
|
614
|
+
|
|
615
|
+
# Code Overview 🎮
|
|
616
|
+
|
|
617
|
+
Project folders/files 📂:
|
|
618
|
+
|
|
619
|
+
Luci_code_tools.py | Main code file
|
|
620
|
+
|
|
621
|
+
A script spanning over 200 lines of code 🐱
|
|
622
|
+
|
|
623
|
+
setup.py | Upload metadata
|
|
624
|
+
|
|
625
|
+
Information transmitted during PyPI upload
|
|
626
|
+
|
|
627
|
+
Includes compatible versions, license details, etc.
|
|
628
|
+
|
|
629
|
+
You can view this information on the left side of the module's webpage 🐱
|
|
630
|
+
|
|
631
|
+
README.md | This document
|
|
632
|
+
|
|
633
|
+
The very document you are reading right now 🐱
|
|
634
|
+
|
|
635
|
+
LICENSE | License (MIT)
|
|
636
|
+
|
|
637
|
+
The *MIT* License is currently **(as of 2026)** the most permissive license available
|
|
638
|
+
|
|
639
|
+
It does not require you to obtain explicit authorization
|
|
640
|
+
|
|
641
|
+
It only asks that you credit the source when redistributing 🐱
|
|
642
|
+
|
|
643
|
+
## Main Code
|
|
644
|
+
|
|
645
|
+
**27** exception handlers
|
|
646
|
+
|
|
647
|
+
Including:
|
|
648
|
+
|
|
649
|
+
*Results* The sections below describe the results defined in the code.
|
|
650
|
+
|
|
651
|
+
In the original code, all **exception handling** scenarios result in an error report.
|
|
652
|
+
|
|
653
|
+
**Error Exit** refers to raising an error due to an invalid state and subsequently terminating the program.
|
|
654
|
+
|
|
655
|
+
For instance, if the program encounters an improper error condition, it should perform an *Error Exit*; this is caught by `SystemExit`.
|
|
656
|
+
|
|
657
|
+
| Error | Meaning | Result |
|
|
658
|
+
| --- | --- | --- |
|
|
659
|
+
| ValueError | Input value type does not match expected type | Retry |
|
|
660
|
+
| KeyboardInterrupt | Error displayed when the command line is interrupted (e.g., Ctrl + C) | Exit + Message |
|
|
661
|
+
| EOFError | End of File; indicates the input stream has been closed | Exit + Message |
|
|
662
|
+
| MemoryError | Error caused by excessive memory usage (e.g., inputting a string exceeding available memory) | Exit (Error Exit) + Message |
|
|
663
|
+
| SystemError | Python interpreter corruption | Exit + Message |
|
|
664
|
+
| OSError | Your system crashed 😂 (likely caused by corrupted system files) | Exit (Error Exit) + Message |
|
|
665
|
+
|
|
666
|
+
There are **27** types of exception handling in total; under normal circumstances, errors ***almost never occur***.
|
|
667
|
+
|
|
668
|
+
# 📦 Installation & Import
|
|
669
|
+
|
|
670
|
+
```bash
|
|
671
|
+
pip install Luci-Code-Tools
|
|
672
|
+
```
|
|
673
|
+
|
|
674
|
+
This installs the latest version by default.
|
|
675
|
+
|
|
676
|
+
You can install a specific version by changing
|
|
677
|
+
|
|
678
|
+
```bash
|
|
679
|
+
pip install <package_name>
|
|
680
|
+
```
|
|
681
|
+
|
|
682
|
+
to
|
|
683
|
+
|
|
684
|
+
```bash
|
|
685
|
+
pip install <package_name>==<version_number>
|
|
686
|
+
```
|
|
687
|
+
|
|
688
|
+
## Import & Reference
|
|
689
|
+
|
|
690
|
+
```python
|
|
691
|
+
|
|
692
|
+
# Note: The example function used in all cases is the 'color' function
|
|
693
|
+
|
|
694
|
+
# Import
|
|
695
|
+
import Luci_code_tools
|
|
696
|
+
Luci_code_tools.color("HelloWorld", 32, None, 1, 2)
|
|
697
|
+
|
|
698
|
+
# Import + as
|
|
699
|
+
import Luci_code_tools as lct
|
|
700
|
+
lct.color("HelloWorld", 32, None, 1, 2)
|
|
701
|
+
|
|
702
|
+
# Reference
|
|
703
|
+
from Luci_code_tools import color
|
|
704
|
+
color("HelloWorld", 32, None, 1, 2)
|
|
705
|
+
|
|
706
|
+
# Reference + as
|
|
707
|
+
from Luci_code_tools import color as cl
|
|
708
|
+
cl("HelloWorld", 32, None, 1, 2)
|
|
709
|
+
|
|
710
|
+
```
|
|
711
|
+
|
|
712
|
+
---
|
|
713
|
+
|
|
714
|
+
# Parameter Introduction
|
|
715
|
+
|
|
716
|
+
The output style for `line` is:
|
|
717
|
+
|
|
718
|
+
```json
|
|
719
|
+
{
|
|
720
|
+
"line": 0,
|
|
721
|
+
"data": "Hello",
|
|
722
|
+
"data": "World",
|
|
723
|
+
"output": 2
|
|
724
|
+
}
|
|
725
|
+
```
|
|
726
|
+
`"output": 2` corresponds to two output functions.
|
|
727
|
+
|
|
728
|
+
Output effect:
|
|
729
|
+
|
|
730
|
+
HelloWorld ("Hello" and "World" are two separate strings)
|
|
731
|
+
|
|
732
|
+
```json
|
|
733
|
+
{
|
|
734
|
+
"line": 1,
|
|
735
|
+
"data": "Hello",
|
|
736
|
+
"data": "World",
|
|
737
|
+
"output": 2
|
|
738
|
+
}
|
|
739
|
+
```
|
|
740
|
+
`"output": 2` corresponds to two output functions.
|
|
741
|
+
|
|
742
|
+
Output effect:
|
|
743
|
+
|
|
744
|
+
Hello
|
|
745
|
+
|
|
746
|
+
(There is actually no blank line here)
|
|
747
|
+
|
|
748
|
+
World
|
|
749
|
+
|
|
750
|
+
```json
|
|
751
|
+
{
|
|
752
|
+
"line": 2,
|
|
753
|
+
"data": "Hello",
|
|
754
|
+
"data": "World",
|
|
755
|
+
"output": 2
|
|
756
|
+
}
|
|
757
|
+
```
|
|
758
|
+
`"output": 2` corresponds to two output functions.
|
|
759
|
+
|
|
760
|
+
Output effect:
|
|
761
|
+
|
|
762
|
+
Hello
|
|
763
|
+
|
|
764
|
+
(There is actually a blank line in between)
|
|
765
|
+
|
|
766
|
+
World
|
|
767
|
+
|
|
768
|
+
The `line` parameter can be set higher, but I need to limit the number of tests due to space constraints 🐱
|
|
769
|
+
|
|
770
|
+
Adjust the number of blank lines numerically to improve readability.
|
|
771
|
+
|
|
772
|
+
## Function Parameters
|
|
773
|
+
|
|
774
|
+
Let's first list the functions currently used in the code.
|
|
775
|
+
|
|
776
|
+
## Functions
|
|
777
|
+
|
|
778
|
+
- color_rgb
|
|
779
|
+
|
|
780
|
+
- color
|
|
781
|
+
|
|
782
|
+
- clear_screen
|
|
783
|
+
|
|
784
|
+
- safe_input
|
|
785
|
+
|
|
786
|
+
- safe_int
|
|
787
|
+
|
|
788
|
+
- safe_float
|
|
789
|
+
|
|
790
|
+
## All Parameters
|
|
791
|
+
|
|
792
|
+
---
|
|
793
|
+
|
|
794
|
+
First, let's introduce **color_rgb**
|
|
795
|
+
|
|
796
|
+
- color_rgb
|
|
797
|
+
|
|
798
|
+
This function manages RGB color output; it is constructed using **ANSI escape sequences + parameters**.
|
|
799
|
+
|
|
800
|
+
Parameters include:
|
|
801
|
+
|
|
802
|
+
data r g b mode line
|
|
803
|
+
|
|
804
|
+
- data
|
|
805
|
+
|
|
806
|
+
The `data` parameter controls the **content to be output**.
|
|
807
|
+
|
|
808
|
+
- r
|
|
809
|
+
|
|
810
|
+
- g
|
|
811
|
+
|
|
812
|
+
- b
|
|
813
|
+
|
|
814
|
+
These three parameters are specified in the order of R, G, and B; for example, `255, 0, 0` represents **pure red**.
|
|
815
|
+
|
|
816
|
+
- mode
|
|
817
|
+
|
|
818
|
+
The `mode` parameter controls the output mode; a table of specific output modes is provided at the end.
|
|
819
|
+
|
|
820
|
+
- line
|
|
821
|
+
|
|
822
|
+
The `line` parameter accepts an integer; specific details can be found in the **"Parameter Introduction"** section above.
|
|
823
|
+
|
|
824
|
+
---
|
|
825
|
+
|
|
826
|
+
- color
|
|
827
|
+
|
|
828
|
+
This function manages colored text using ANSI escape sequences 🤔
|
|
829
|
+
|
|
830
|
+
- data
|
|
831
|
+
|
|
832
|
+
Manages the string to be output with color formatting.
|
|
833
|
+
|
|
834
|
+
- text_color
|
|
835
|
+
|
|
836
|
+
Controls the output color using ANSI color codes; no need for complex adjustments. Detailed parameters are in the parameter table at the end.
|
|
837
|
+
|
|
838
|
+
- bg_color
|
|
839
|
+
|
|
840
|
+
Controls the background color of the output using ANSI color codes. Detailed parameters are in the parameter table at the end.
|
|
841
|
+
|
|
842
|
+
- mode
|
|
843
|
+
|
|
844
|
+
Controls the output/display style using ANSI escape sequences.
|
|
845
|
+
|
|
846
|
+
- line
|
|
847
|
+
|
|
848
|
+
Serves the same purpose as the `color_rgb` parameter mentioned earlier; both control the number of blank lines between outputs.
|
|
849
|
+
|
|
850
|
+
---
|
|
851
|
+
|
|
852
|
+
- clear_screen
|
|
853
|
+
|
|
854
|
+
`clear_screen` takes no arguments, but here is an introduction to the function.
|
|
855
|
+
|
|
856
|
+
**Function Introduction**
|
|
857
|
+
|
|
858
|
+
This function:
|
|
859
|
+
|
|
860
|
+
> Automatically detects the system and uses the corresponding screen-clearing command.
|
|
861
|
+
|
|
862
|
+
For example:
|
|
863
|
+
|
|
864
|
+
Android -> `clear` (Linux kernel)
|
|
865
|
+
|
|
866
|
+
Linux -> `clear`
|
|
867
|
+
|
|
868
|
+
Windows -> `cls`
|
|
869
|
+
|
|
870
|
+
It switches the command used based on the OS.
|
|
871
|
+
|
|
872
|
+
> Ensures absolute protection against injection attacks by using a controlled list of parameters and commands for clearing the screen.
|
|
873
|
+
|
|
874
|
+
> Can use the `shutil` module to detect terminal height and output the appropriate number of blank lines, even in environments without a command-line interface (where `clear` or `cls` commands are unavailable).
|
|
875
|
+
|
|
876
|
+
> Can output 250 blank lines to "clear the screen" even if the terminal height cannot be detected.
|
|
877
|
+
|
|
878
|
+
---
|
|
879
|
+
|
|
880
|
+
- safe_input
|
|
881
|
+
|
|
882
|
+
- safe_int
|
|
883
|
+
|
|
884
|
+
- safe_float
|
|
885
|
+
|
|
886
|
+
These `safe_*` functions share the same parameters:
|
|
887
|
+
|
|
888
|
+
prompt | Prompt text
|
|
889
|
+
|
|
890
|
+
text_color | Prompt text color
|
|
891
|
+
|
|
892
|
+
bg_color | Prompt background color
|
|
893
|
+
|
|
894
|
+
mode | Prompt output style
|
|
895
|
+
|
|
896
|
+
- prompt
|
|
897
|
+
|
|
898
|
+
The `prompt` parameter serves the same purpose as the `data` parameter.
|
|
899
|
+
|
|
900
|
+
- text_color
|
|
901
|
+
|
|
902
|
+
- bg_color
|
|
903
|
+
|
|
904
|
+
- mode
|
|
905
|
+
|
|
906
|
+
These three parameters are identical to the corresponding ones in `color` and `color_rgb`, serving the same function.
|
|
907
|
+
|
|
908
|
+
---
|
|
909
|
+
|
|
910
|
+
# Parameter Table
|
|
911
|
+
|
|
912
|
+
## Foreground Color
|
|
913
|
+
|
|
914
|
+
| Foreground Color - Value | Effect |
|
|
915
|
+
| --- | --- |
|
|
916
|
+
| 30 | Black |
|
|
917
|
+
| 31 | Red |
|
|
918
|
+
| 32 | Green |
|
|
919
|
+
| 33 | Yellow |
|
|
920
|
+
| 34 | Blue |
|
|
921
|
+
| 35 | Purple |
|
|
922
|
+
| 36 | Cyan |
|
|
923
|
+
| 37 | White |
|
|
924
|
+
|
|
925
|
+
## Foreground Color - Light/Bright
|
|
926
|
+
|
|
927
|
+
| Foreground Color - Value | Effect |
|
|
928
|
+
| --- | --- |
|
|
929
|
+
| 90 | Dark gray |
|
|
930
|
+
| 91 | Light red |
|
|
931
|
+
| 92 | Light green |
|
|
932
|
+
| 93 | Light yellow |
|
|
933
|
+
| 94 | Light blue |
|
|
934
|
+
| 95 | Light purple |
|
|
935
|
+
| 96 | Light cyan |
|
|
936
|
+
| 97 | Light gray |
|
|
937
|
+
|
|
938
|
+
## Background Color
|
|
939
|
+
|
|
940
|
+
| Background Color - Value | Effect |
|
|
941
|
+
| --- | --- |
|
|
942
|
+
| 40 | Black |
|
|
943
|
+
| 41 | Red |
|
|
944
|
+
| 42 | Green |
|
|
945
|
+
| 43 | Yellow |
|
|
946
|
+
| 44 | Blue |
|
|
947
|
+
| 45 | Purple |
|
|
948
|
+
| 46 | Cyan |
|
|
949
|
+
| 47 | White |
|
|
950
|
+
|
|
951
|
+
## Background Color - Light Shades
|
|
952
|
+
|
|
953
|
+
| Background Color - Value | Effect |
|
|
954
|
+
| --- | --- |
|
|
955
|
+
| 100 | Dark gray |
|
|
956
|
+
| 101 | Light red |
|
|
957
|
+
| 102 | Light green |
|
|
958
|
+
| 103 | Light yellow |
|
|
959
|
+
| 104 | Light blue |
|
|
960
|
+
| 105 | Light purple |
|
|
961
|
+
| 106 | Light cyan |
|
|
962
|
+
| 107 | Pure white |
|
|
963
|
+
|
|
964
|
+
## Output Mode
|
|
965
|
+
|
|
966
|
+
| Display Mode - Value | Effect |
|
|
967
|
+
| --- | --- |
|
|
968
|
+
| 0 | Default |
|
|
969
|
+
| 1 | Highlight + Bold |
|
|
970
|
+
| 2 | Dim |
|
|
971
|
+
| 3 | Italic (may not be supported by some terminals) |
|
|
972
|
+
| 4 | Underline |
|
|
973
|
+
| 5 | Blink |
|
|
974
|
+
| 6 | Rapid blink (may not be supported by some terminals) |
|
|
975
|
+
| 7 | Invert (swap foreground and background colors) |
|
|
976
|
+
| 8 | Hidden |
|
|
977
|
+
| 9 | Strikethrough |
|
|
978
|
+
|
|
979
|
+
---
|
|
980
|
+
|
|
981
|
+
# Credits & Acknowledgments (Ranked by contribution level, top to bottom)
|
|
982
|
+
|
|
983
|
+
| Person/Entity | Contribution |
|
|
984
|
+
| --- | --- |
|
|
985
|
+
| DeepSeek | Build, packaging, and upload tutorial |
|
|
986
|
+
| DeepSeek | Provided improvement suggestions |
|
|
987
|
+
| DeepSeek | Environment help |
|
|
988
|
+
| Luci_Code | Writing |
|
|
989
|
+
| Luci_Code | Packaging |
|
|
990
|
+
| Luci_Code | Creation |
|
|
991
|
+
| Luci_Code | Building |
|
|
992
|
+
| Luci_Code | Uploading |
|
|
993
|
+
| Luci_Code | Conceptualization |
|
|
994
|
+
|
|
995
|
+
---
|
|
996
|
+
|
|
997
|
+
# Quick Start
|
|
998
|
+
|
|
999
|
+
## Input and Output
|
|
1000
|
+
|
|
1001
|
+
```python
|
|
1002
|
+
from Luci_code_tools import color, safe_input
|
|
1003
|
+
|
|
1004
|
+
text = safe_input("Please enter text: ", 32, None, 1)
|
|
1005
|
+
color(f"You entered {text}", 32, None, 1, 2)
|
|
1006
|
+
```
|
|
1007
|
+
|
|
1008
|
+
## Calculator
|
|
1009
|
+
|
|
1010
|
+
```python
|
|
1011
|
+
from Luci_code_tools import color, safe_float, safe_input
|
|
1012
|
+
from sys import exit
|
|
1013
|
+
|
|
1014
|
+
color("=== Calculator ===", 32, None, 1, 2)
|
|
1015
|
+
while True:
|
|
1016
|
+
num1 = safe_float("Enter the first number: ", 32, None, 1)
|
|
1017
|
+
num2 = safe_float("Enter the second number: ", 32, None, 1)
|
|
1018
|
+
operators = safe_input("Enter operator (+, -, *, /, type 'quit' to exit): ")
|
|
1019
|
+
if operators == "+":
|
|
1020
|
+
color(f"Result: {num1 + num2}\n==========", 32, None, 1, 2)
|
|
1021
|
+
continue
|
|
1022
|
+
elif operators == "-":
|
|
1023
|
+
color(f"Result: {num1 - num2}\n==========", 32, None, 1, 2)
|
|
1024
|
+
continue
|
|
1025
|
+
elif operators == "*":
|
|
1026
|
+
color(f"Result: {num1 * num2}\n==========", 32, None, 1, 2)
|
|
1027
|
+
continue
|
|
1028
|
+
elif operators == "/":
|
|
1029
|
+
if num2 == 0:
|
|
1030
|
+
color("Divisor cannot be zero\n==========", 33, None, 1, 2)
|
|
1031
|
+
continue
|
|
1032
|
+
else:
|
|
1033
|
+
color(f"Result: {num1 / num2}\n==========", 32, None, 1, 2)
|
|
1034
|
+
continue
|
|
1035
|
+
elif operators == "quit":
|
|
1036
|
+
color("=== Exit successful ===", 32, None, 1, 2)
|
|
1037
|
+
exit(0)
|
|
1038
|
+
else:
|
|
1039
|
+
color("Invalid operator!\n==========", 33, None, 1, 2)
|
|
1040
|
+
continue
|
|
1041
|
+
```
|
|
1042
|
+
|
|
1043
|
+
## File Read and Write
|
|
1044
|
+
|
|
1045
|
+
```python
|
|
1046
|
+
from Luci_code_tools import color
|
|
1047
|
+
from os import remove
|
|
1048
|
+
from json import load, dump, JSONDecodeError
|
|
1049
|
+
|
|
1050
|
+
JSON = {
|
|
1051
|
+
"test": "This is Test content",
|
|
1052
|
+
"test2": "This is Test content 2"
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
FILE_PATH = "user.json"
|
|
1056
|
+
|
|
1057
|
+
def fix_json(prompt: str) -> None:
|
|
1058
|
+
color(prompt, 33, None, 1, 2)
|
|
1059
|
+
with open(FILE_PATH, "w", encoding="utf-8") as f:
|
|
1060
|
+
dump(JSON, f, ensure_ascii=False, indent=4, sort_keys=True)
|
|
1061
|
+
color("Repair successful! Please restart the program", 32, None, 1)
|
|
1062
|
+
|
|
1063
|
+
try:
|
|
1064
|
+
with open(FILE_PATH, "r", encoding="utf-8") as f:
|
|
1065
|
+
data = load(f)
|
|
1066
|
+
except FileNotFoundError:
|
|
1067
|
+
fix_json("File not found, repairing...")
|
|
1068
|
+
except JSONDecodeError:
|
|
1069
|
+
fix_json("JSON file format or content error")
|
|
1070
|
+
else:
|
|
1071
|
+
content_1 = data["test"]
|
|
1072
|
+
content_2 = data["test2"]
|
|
1073
|
+
color(f"Content 1: {content_1}\nContent 2: {content_2}\n\nTest successful!", 32, None, 1, 2)
|
|
1074
|
+
remove(FILE_PATH)
|
|
1075
|
+
```
|