> For the complete documentation index, see [llms.txt](https://gitbook.existorlive.cn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.existorlive.cn/kai-fa-yu-yan-xue-xi/python/14.-shu-ru-shu-chu-ge-shi-hua.md).

# 14.输入输出格式化

## 1. 标准输入 (`input`)

`input` 函数接收命令行输入

![](https://pic.existorlive.cn/202112240034845.png)

## 2. 标准输出 (`print`)

`print` 函数用于将字符串输出到命令行中

### 2.1 str()/repr()

* `str()` ： 函数返回一个用户易读的表达形式。
* `repr()`: 产生一个解释器易读的表达形式

### 2.2 rjust()/ljust()/center()

用**空格**将字符串补全至目标长度；

* rjust(num) ： 右对齐
* ljust(num) ： 左对齐
* center(num) ： 局中

![](https://pic.existorlive.cn/202112240100826.png)

### 2.3 zfill()

在数字左边填充 0

![](https://pic.existorlive.cn/202112240102695.png)
