PY:バッチテキスト

あなたはうまく彼らのパッケージの名前を変更、ファイルの束をコピーするために、他の誰かのコードをダウンロードしてください。

投稿者:


へ:
ここに画像を挿入説明

#!/usr/bin/python
# -*- coding: UTF-8 -*-
import re
import os


fileNameList = os.listdir(os.getcwd())
fileNameList.remove("nameBatchChange.py")
fileNameList.remove(".DS_Store")

for file in fileNameList:
	new_str = ""
	with open(file, 'r') as f:
		for eachLine in f:
			if re.search(r'package com.thirtydegreesray.openhub', eachLine):
				eachLine = re.sub('package com.thirtydegreesray.openhub', 'package com.paulkg12.t60', eachLine)

			new_str += eachLine
	print(new_str)
	wopen = open(file, 'w')
	wopen.write(new_str)
	f.close()
	wopen.close()

公開された216元の記事 ウォン称賛33 ビュー90000 +

おすすめ

転載: blog.csdn.net/paulkg12/article/details/104816744