程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python finds a specific file and changes its information

編輯:Python

Python Find a specific file , And change the file information

  • 1. Find a specific project file
  • 2. Compare the difference between the two projects

demand : According to the modified keil engineering , Change other projects together

  1. Find all project folders
  2. Compare the differences between the engineering documents before and after the modification
  3. List the differences separately , Or show
  4. Change all the codes in other projects

1. Find a specific project file

cFileNumber: Indicates the number of files found

import os
cFileNumber = 0
dir = './' # The path where the project is located
#dir = 'D://BuildArea//10031799_MT62P3_MiniAPP//10031799_HAL' # Absolute path 
for root, dirs, files in os.walk(dir): # Traverse the folder
for file in files: # Traverse the newly obtained file name files
(filename, extension) = os.path.splitext(file) # Split the file name into file name and suffix
if (extension == '.uvprojx'): # Determine whether the suffix is .c file
cFileNumber= cFileNumber+1 # Record .c The number of files is the corresponding file number
print(cFileNumber, os.path.join(root,filename)) # Output file number and corresponding path plus file name
#print("PLACE_RAM(" + filename + ')') # With PLACE_RAM( file name ) Format output file name 

2. Compare the difference between the two projects


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved