Modifikation von Python 2.x.x mit Python 3.x.x & Methode zur Umwandlung von Python 2.x.x in Python 3.x.x

Schriftsteller:Kleine Träume, Erstellt: 2016-10-09 12:36:49, Aktualisiert: 2017-10-11 10:18:05

Das ist der Code.

Die Daten wurden in einem anderen Backups-Datei (34563264_data_from_site.py.bak) zusammengefügt, um den Unterschied zu erkennen.

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

Ich möchte Ihnen sagen, wie ich meine eigene Situation verstanden habe.

(1) Wenn die obigen -w-Parameter nicht hinzugefügt werden, wird standardmäßig nur der Diff-Inhalt gedruckt, der dem Umwandlungsprozess entspricht.

(2) Hinzufügen von -w bedeutet, dass die Änderungen zurückgeschrieben wurden.

(3) Wenn Sie keine bak-Datei erstellen möchten, können Sie -n hinzufügen.

(4) Ich will nicht die Menge an Ausgabe sehen, plus die "no-diffs" und so weiter.

Die anderen sind nicht sehr gut beschrieben.

Die Verwendung von 2to3 obenAuf der Straße

Ich habe es überarbeitet, und wenn es Fehler gibt, freue ich mich, es zu zeigen! ^_^


Mehr

FangBeiWas ist mit Python 2 für botvs?

Kleine TräumeDer Retest-Server von BotVS verwendet die Python 2.7-Version, die für die BotVS-Plattform Python 2 und Python 3 unterstützt wird.