2to3: add Chinese translation (#6323)

beep
千玄子 2021-08-16 01:47:13 +08:00 committed by GitHub
parent 2bef4512ef
commit 3fbefc8b77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 32 additions and 0 deletions

32
pages.zh/common/2to3.md Normal file
View File

@ -0,0 +1,32 @@
# 2to3
> 自动将 Python 2 代码转换成 Python 3.
> 更多信息:<https://docs.python.org/3/library/2to3.html>.
- 显示将执行的变动但不执行dry-run
`2to3 {{文件.py}}`
- 将 Python 2 文件转化为 Python 3:
`2to3 --write {{文件.py}}`
- 将 Python 2 语言特性转化为 Python 3:
`2to3 --write {{文件.py}} --fix={{raw_input}} --fix={{print}}`
- 除了某个语言特性外将所有其他的 Python 2 语言特性转化为 Python 3:
`2to3 --write {{文件.py}} --nofix={{has_key}} --nofix={{isinstance}}`
- 列出 Python 2 所有可转化为 Python 3 的语言特性:
`2to3 --list-fixes`
- 将某一文件夹的所有 Python 2 文件转化为 Python 3:
`2to3 --output-dir={{Python 3 文件夹}} --write-unchanged-files --nobackups {{Python 2 文件夹}}`
- 使用多线程运行 2to3:
`2to3 --processes={{4}} --output-dir={{Python 3 文件夹}} --write --nobackups --no-diff {{Python 2 文件夹}}`