資源簡介
圖片-xml匹配、重命名、讀取xml并重新生成xml

代碼片段和文件信息
#!/usr/bin/env?python
#?-*-?coding:?utf-8?-*-
import?os
import?re
import?shutil
origin_dir?=?‘D:\\ocr\\five_categories\\5_class_icon5\\5_class_icon4_labeled\\collect‘???#xml和jpg數量不對的目錄
target_dir?=?‘D:\\ocr\\five_categories\\5_class_icon5\\5_class_icon4_labeled\\collect-after‘????#轉移后的目錄
pattern?=?re.compile(‘(.*)\.(.*)‘)
def?to_move():
????cursor?=?None
????last_name?=?None
????for?f?in?sorted(os.listdir(origin_dir)):
????????try:
????????????name?postfix?=?re.match(pattern?f).groups()
????????????if?name?==?cursor:
????????????????yield?last_name
????????????????yield?f
????????????else:
????????????????cursor?=?name
????????????????last_name?=?f
????????except?Exception?as?e:
????????????print(e)
for?i?in?to_move():
????origin?=?os.path.join(origin_dir?i)
????if?os.path.isfile(origin):
????????target?=?os.path.join(target_dir?i)
????????print(‘move?{origin}?to?{target}‘)
????????shutil.move(origin?target)
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????5090??2019-03-28?21:05??my_icdar13_to_voc.py
?????文件????????3305??2019-04-11?21:34??voc_to_icdar13.py
?????文件?????????995??2019-04-13?22:22??match_quantity.py
?????目錄???????????0??2019-04-13?22:22??__MACOSX\
?????文件?????????176??2019-04-13?22:22??__MACOSX\._match_quantity.py
?????文件?????????274??2019-03-28?20:28??rename.py
- 上一篇:學生作業管理python實現
- 下一篇:lua加密工具.zip
評論
共有 條評論