python2代码升级到python3工具

python模块lib2to3(py2转py3自动化工具)
 1 Usage: 2to3 [options] file|dir ...
 2 
 3 Options:
 4   -h, --help            show this help message and exit
 5   -d, --doctests_only   Fix up doctests only
 6   -f FIX, --fix=FIX     Each FIX specifies a transformation; default: all
 7   -j PROCESSES, --processes=PROCESSES
 8                         Run 2to3 concurrently
 9   -x NOFIX, --nofix=NOFIX
10                         Prevent a transformation from being run
11   -l, --list-fixes      List available transformations
12   -p, --print-function  Modify the grammar so that print() is a function
13   -v, --verbose         More verbose logging
14   --no-diffs            Don't show diffs of the refactoring
15   -w, --write           Write back modified files
16   -n, --nobackups       Don't write backups for modified files
17   -o OUTPUT_DIR, --output-dir=OUTPUT_DIR
18                         Put output files in this directory instead of
19                         overwriting the input files.  Requires -n.
20   -W, --write-unchanged-files
21                         Also write files even if no changes were required
22                         (useful with --output-dir); implies -w.
23   --add-suffix=ADD_SUFFIX
24                         Append this string to all output filenames. Requires
25                         -n if non-empty.  ex: --add-suffix='3' will generate
26                         .py3 files.

eg:2to3 -w test.py

猜你喜欢

转载自www.cnblogs.com/buyizhiyou/p/8966583.html