Python 2.x.x 与 Python 3.x.x 的改动 & Python 2.x.x 转换为 Python 3.x.x 的方法

Author: 小小梦, Created: 2016-10-09 12:36:49, Updated: 2017-10-11 10:18:05

码了。

对应的,也多出一个bak文件:34563264_data_from_site.py.bak,两者比较一下,即可看出区别:

img

当前,对于2to3.py本身,也可以通过help查看到更多的用法:

D:\tmp\tmp_dev_root\python\python2_to_python3>D:\tmp\WordPress\DevRoot\Python27\Tools\Scripts\2to3.py -h
Usage: 2to3 [options] file|dir ...
 
Options:
  -h, --help            show this help message and exit
  -d, --doctests_only   Fix up doctests only
  -f FIX, --fix=FIX     Each FIX specifies a transformation; default: all
  -j PROCESSES, --processes=PROCESSES
                        Run 2to3 concurrently
  -x NOFIX, --nofix=NOFIX
                        Prevent a transformation from being run
  -l, --list-fixes      List available transformations
  -p, --print-function  Modify the grammar so that print() is a function
  -v, --verbose         More verbose logging
  --no-diffs            Don't show diffs of the refactoring
  -w, --write           Write back modified files
  -n, --nobackups       Don't write backups for modified files

此处只多解释几句:

(1)如果上述不加-w参数,则默认只是把转换过程所对应的diff内容打印输出到当前窗口而已。

(2)加了-w,就是把改动内容,写回到原先的文件了。

(3)不想要生成bak文件,再加上-n即可。

(4)不想看到那一堆输出的内容,加上–no-diffs,即可。

其他的,就不多介绍了。感兴趣的可以自己去继续折腾。

以上2to3的用法 转载自 在路上

重新编辑了,如有错误,欢迎指出! ^_^


More

FangBei botvs用的python2?

小小梦 BotVS 的回测服务器 使用的是Python 2.7版本, 对于BotVS 平台 Python2 ,Python3 都是支持的。