python 2一括変換python 3スクリプト
954 ワード
python独自のツール2 to 3を利用する.py一括変換完了!
import os
#
def Python2toPython3(dirname, p2to3FileName):
if os.path.exists(dirname):
for dirpath, dirnames, filenames in os.walk(dirname):
for filename in filenames:
if filename.endswith('.py'):
fileFullName = os.path.join(dirpath, filename)
print(('Processing File:', fileFullName))
# -w -n .bak
# -f
pycode2to3 = ("python " + p2to3FileName + " -w " +
fileFullName)
print((os.popen(pycode2to3, 'r').read()))
# dirname
dirname = os.getcwd()
# p2to3FileName Python 2to3.py ,2to3.py python
p2to3FileName = (r'H:\python3.6.5\Tools\scripts\2to3.py')
Python2toPython3(dirname, p2to3FileName)