模块名称 NAME
=============
::
console_tool
简介 DESCRIPTION
================
::
提供创建命令行程序工具的模块,包含Console类。
A module for creating command line programs.
包含的类 CLASSES
''''''''''''''''
类继承顺序::
builtins.object::
ColoredTextWrapper
Console
colorama.ansi.AnsiCursor(builtins.object)::
Cursor
class Console
""""""""""""""""""""""""""""""
bell(self, times=1, delay=False)::
将振铃符发送至终端,发出响铃声。
times:响铃次数
delay:开始响铃后是否立即返回,默认为False。
clear(self)
清除命令行窗口中的所有文本, 这将调用系统的cls或clear命令。
color(self, backcolor='', forecolor='')::
改变命令行窗口的前景和背景颜色
与coloredtext方法不同,color改变整个窗口的颜色
该方法调用系统的color命令
如::
color("blue","green") -- 设置前景颜色为绿色,背景颜色为蓝色
color() -- 恢复默认颜色
可用的颜色: black, blue, green, aqua, red, purple, yellow, white, gray, light_blue, light_green, light_aqua, light_red, light_purple, light_yellow, bright_white
coloredtext(self, string, color='white', highlight=None, \*args, end='\n', flush=False, reset=True)::
输出一段带颜色的文本
如:coloredtext("Hello world!",color="green",highlight="black","bold") --
输出绿色、加粗的文字'Hello world!'
别名: ctext
colorize(self, stdout='blue', stderr='red', bold=True)::
初始化带颜色的输出,类似于IDLE。
colorize(stdout="cyan",stderr="magenta") - 设置输出消息为青色,错误消息为紫色。
colorize(stderr=None) - 只设置输出消息(sys.stdout)的颜色。
input(self, prompt='', chars_to_read=None, \*\*kwargs)::
获取用户的输入。
prompt:提示(默认显示为白色)
chars_to_read:要从sys.stdin读取多少个字符
print_slowly(self, iterable_of_str, delay=0, \*args, \*\*kwargs)::
缓慢地打印出一段文本
iterable_of_str:待打印的内容(字符串或可迭代对象)
reset(self)::
与colorize方法相反,停止带颜色的输出。
title(self, title)::
设置命令行窗口标题。
新增方法:
resize(self, cols, lines)::
缩放窗口。cols: 列数, lines: 行数
chcp(self, codepage)::
改变活动代码页, 使用chcp命令
class Cursor
""""""""""""""""""""""""""""""""""""""
Cursor(outfile=sys.stdout)
命令行中的光标类
down(self, distance=1)
向下移动光标,距离为distance。
left(self, distance=1)
向左移动光标,距离为distance。
pos(self, x=1, y=1)
移动光标至指定位置(x,y)。
如果不提供参数x,y,则移动光标至屏幕左上角。
right(self, distance=1)
向右移动光标,距离为distance。
up(self, distance=1)
向上移动光标,距离为distance。
class ColoredTextWrapper(builtins.object)
ColoredTextWrapper(file=sys.stdout, color='white', bold=True)
在命令行提供带颜色的输出流,类似于IDLE
flush(self)
write(self, string)
示例代码 EXAMPLES
=================
.. code-block:: python
c=Console() #初始化Console对象
c.colorize()
c.title("console_tool.py (Test)")
c.coloredtext("Hello world!","green","magenta","blink") # 输出绿色的Hello world!
版本 VERSION
============
1.2.4
作者 AUTHOR
===========
七分诚意 qq:3076711200 贴吧账号:qfcy\_
作者CSDN主页: https://blog.csdn.net/qfcy\_
Raw data
{
"_id": null,
"home_page": "https://github.com/qfcy/Python/blob/main/Terminal/console_tool.py",
"name": "console-tool",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "terminal,command-line,console,cmd,\u63a7\u5236\u53f0\u7a97\u53e3",
"author": "\u4e03\u5206\u8bda\u610f qq:3076711200",
"author_email": "3076711200@qq.com",
"download_url": "https://files.pythonhosted.org/packages/a1/c9/6592d45d03a9d9f7e764b00bc6e583eb74790bcbd20e28f92ea31254e038/console-tool-1.2.4.tar.gz",
"platform": null,
"description": "\u6a21\u5757\u540d\u79f0 NAME\r\n=============\r\n\r\n::\r\n\r\n console_tool\r\n\r\n\u7b80\u4ecb DESCRIPTION\r\n================\r\n\r\n::\r\n\r\n \u63d0\u4f9b\u521b\u5efa\u547d\u4ee4\u884c\u7a0b\u5e8f\u5de5\u5177\u7684\u6a21\u5757,\u5305\u542bConsole\u7c7b\u3002\r\n A module for creating command line programs.\r\n\r\n\u5305\u542b\u7684\u7c7b CLASSES\r\n''''''''''''''''\r\n\u7c7b\u7ee7\u627f\u987a\u5e8f::\r\n\r\n builtins.object::\r\n ColoredTextWrapper\r\n Console\r\n colorama.ansi.AnsiCursor(builtins.object)::\r\n Cursor\r\n\r\nclass Console\r\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\r\n bell(self, times=1, delay=False)::\r\n\r\n \u5c06\u632f\u94c3\u7b26\u53d1\u9001\u81f3\u7ec8\u7aef,\u53d1\u51fa\u54cd\u94c3\u58f0\u3002\r\n times:\u54cd\u94c3\u6b21\u6570\r\n delay:\u5f00\u59cb\u54cd\u94c3\u540e\u662f\u5426\u7acb\u5373\u8fd4\u56de,\u9ed8\u8ba4\u4e3aFalse\u3002\r\n \r\n clear(self)\r\n \u6e05\u9664\u547d\u4ee4\u884c\u7a97\u53e3\u4e2d\u7684\u6240\u6709\u6587\u672c, \u8fd9\u5c06\u8c03\u7528\u7cfb\u7edf\u7684cls\u6216clear\u547d\u4ee4\u3002\r\n \r\n color(self, backcolor='', forecolor='')::\r\n\r\n \u6539\u53d8\u547d\u4ee4\u884c\u7a97\u53e3\u7684\u524d\u666f\u548c\u80cc\u666f\u989c\u8272\r\n \u4e0ecoloredtext\u65b9\u6cd5\u4e0d\u540c,color\u6539\u53d8\u6574\u4e2a\u7a97\u53e3\u7684\u989c\u8272\r\n \u8be5\u65b9\u6cd5\u8c03\u7528\u7cfb\u7edf\u7684color\u547d\u4ee4\r\n \u5982::\r\n\r\n color(\"blue\",\"green\") -- \u8bbe\u7f6e\u524d\u666f\u989c\u8272\u4e3a\u7eff\u8272,\u80cc\u666f\u989c\u8272\u4e3a\u84dd\u8272\r\n color() -- \u6062\u590d\u9ed8\u8ba4\u989c\u8272\r\n\r\n \u53ef\u7528\u7684\u989c\u8272: black, blue, green, aqua, red, purple, yellow, white, gray, light_blue, light_green, light_aqua, light_red, light_purple, light_yellow, bright_white\r\n\r\n coloredtext(self, string, color='white', highlight=None, \\*args, end='\\n', flush=False, reset=True)::\r\n\r\n \u8f93\u51fa\u4e00\u6bb5\u5e26\u989c\u8272\u7684\u6587\u672c\r\n \u5982:coloredtext(\"Hello world!\",color=\"green\",highlight=\"black\",\"bold\") --\r\n \u8f93\u51fa\u7eff\u8272\u3001\u52a0\u7c97\u7684\u6587\u5b57'Hello world!'\r\n \u522b\u540d: ctext\r\n\r\n colorize(self, stdout='blue', stderr='red', bold=True)::\r\n\r\n \u521d\u59cb\u5316\u5e26\u989c\u8272\u7684\u8f93\u51fa,\u7c7b\u4f3c\u4e8eIDLE\u3002\r\n colorize(stdout=\"cyan\",stderr=\"magenta\") - \u8bbe\u7f6e\u8f93\u51fa\u6d88\u606f\u4e3a\u9752\u8272,\u9519\u8bef\u6d88\u606f\u4e3a\u7d2b\u8272\u3002\r\n colorize(stderr=None) - \u53ea\u8bbe\u7f6e\u8f93\u51fa\u6d88\u606f(sys.stdout)\u7684\u989c\u8272\u3002\r\n\r\n input(self, prompt='', chars_to_read=None, \\*\\*kwargs)::\r\n\r\n \u83b7\u53d6\u7528\u6237\u7684\u8f93\u5165\u3002\r\n prompt:\u63d0\u793a(\u9ed8\u8ba4\u663e\u793a\u4e3a\u767d\u8272)\r\n chars_to_read:\u8981\u4ecesys.stdin\u8bfb\u53d6\u591a\u5c11\u4e2a\u5b57\u7b26\r\n\r\n print_slowly(self, iterable_of_str, delay=0, \\*args, \\*\\*kwargs)::\r\n\r\n \u7f13\u6162\u5730\u6253\u5370\u51fa\u4e00\u6bb5\u6587\u672c\r\n iterable_of_str:\u5f85\u6253\u5370\u7684\u5185\u5bb9(\u5b57\u7b26\u4e32\u6216\u53ef\u8fed\u4ee3\u5bf9\u8c61)\r\n\r\n reset(self)::\r\n\r\n \u4e0ecolorize\u65b9\u6cd5\u76f8\u53cd,\u505c\u6b62\u5e26\u989c\u8272\u7684\u8f93\u51fa\u3002\r\n\r\n title(self, title)::\r\n\r\n \u8bbe\u7f6e\u547d\u4ee4\u884c\u7a97\u53e3\u6807\u9898\u3002\r\n\r\n \u65b0\u589e\u65b9\u6cd5:\r\n\r\n resize(self, cols, lines)::\r\n\r\n \u7f29\u653e\u7a97\u53e3\u3002cols: \u5217\u6570, lines: \u884c\u6570\r\n\r\n chcp(self, codepage)::\r\n\r\n \u6539\u53d8\u6d3b\u52a8\u4ee3\u7801\u9875, \u4f7f\u7528chcp\u547d\u4ee4\r\n\r\n\r\nclass Cursor\r\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\r\n Cursor(outfile=sys.stdout)\r\n \r\n \u547d\u4ee4\u884c\u4e2d\u7684\u5149\u6807\u7c7b\r\n \r\n down(self, distance=1)\r\n \u5411\u4e0b\u79fb\u52a8\u5149\u6807,\u8ddd\u79bb\u4e3adistance\u3002\r\n \r\n left(self, distance=1)\r\n \u5411\u5de6\u79fb\u52a8\u5149\u6807,\u8ddd\u79bb\u4e3adistance\u3002\r\n \r\n pos(self, x=1, y=1)\r\n \u79fb\u52a8\u5149\u6807\u81f3\u6307\u5b9a\u4f4d\u7f6e(x,y)\u3002\r\n \u5982\u679c\u4e0d\u63d0\u4f9b\u53c2\u6570x,y,\u5219\u79fb\u52a8\u5149\u6807\u81f3\u5c4f\u5e55\u5de6\u4e0a\u89d2\u3002\r\n \r\n right(self, distance=1)\r\n \u5411\u53f3\u79fb\u52a8\u5149\u6807,\u8ddd\u79bb\u4e3adistance\u3002\r\n \r\n up(self, distance=1)\r\n \u5411\u4e0a\u79fb\u52a8\u5149\u6807,\u8ddd\u79bb\u4e3adistance\u3002\r\n\r\nclass ColoredTextWrapper(builtins.object)\r\n ColoredTextWrapper(file=sys.stdout, color='white', bold=True)\r\n\r\n \u5728\u547d\u4ee4\u884c\u63d0\u4f9b\u5e26\u989c\u8272\u7684\u8f93\u51fa\u6d41,\u7c7b\u4f3c\u4e8eIDLE\r\n \r\n flush(self)\r\n \r\n write(self, string)\r\n\r\n\u793a\u4f8b\u4ee3\u7801 EXAMPLES\r\n=================\r\n\r\n.. code-block:: python\r\n\r\n c=Console() #\u521d\u59cb\u5316Console\u5bf9\u8c61\r\n c.colorize() \r\n c.title(\"console_tool.py (Test)\")\r\n c.coloredtext(\"Hello world!\",\"green\",\"magenta\",\"blink\") # \u8f93\u51fa\u7eff\u8272\u7684Hello world!\r\n\r\n\u7248\u672c VERSION\r\n============\r\n 1.2.4\r\n\r\n\u4f5c\u8005 AUTHOR\r\n===========\r\n \u4e03\u5206\u8bda\u610f qq:3076711200 \u8d34\u5427\u8d26\u53f7:qfcy\\_\r\n\r\n \u4f5c\u8005CSDN\u4e3b\u9875: https://blog.csdn.net/qfcy\\_\r\n",
"bugtrack_url": null,
"license": "",
"summary": "\u63d0\u4f9b\u521b\u5efa\u547d\u4ee4\u884c\u7a0b\u5e8f\u5de5\u5177\u7684\u6a21\u5757,\u5305\u542bConsole\u7c7b\u3002A module for creating command line programs.",
"version": "1.2.4",
"project_urls": {
"Homepage": "https://github.com/qfcy/Python/blob/main/Terminal/console_tool.py"
},
"split_keywords": [
"terminal",
"command-line",
"console",
"cmd",
"\u63a7\u5236\u53f0\u7a97\u53e3"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a1c96592d45d03a9d9f7e764b00bc6e583eb74790bcbd20e28f92ea31254e038",
"md5": "866aaeca2569e21a94b1e2bf99d9a417",
"sha256": "f24aed965682579ee83d7a89d8b5451dce4a0991954d697856ad358bf506f0dd"
},
"downloads": -1,
"filename": "console-tool-1.2.4.tar.gz",
"has_sig": false,
"md5_digest": "866aaeca2569e21a94b1e2bf99d9a417",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5745,
"upload_time": "2024-01-09T12:14:21",
"upload_time_iso_8601": "2024-01-09T12:14:21.876557Z",
"url": "https://files.pythonhosted.org/packages/a1/c9/6592d45d03a9d9f7e764b00bc6e583eb74790bcbd20e28f92ea31254e038/console-tool-1.2.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-09 12:14:21",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "qfcy",
"github_project": "Python",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "console-tool"
}