# -*- coding: utf-8 -*-
import os
def add_text(path,filepath:list):
path_list = os.listdir(path)
print(path_list)
for i in path_list:
for p in filepath:
if p == i:
add_path = os.path.join(path,i)
file = os.listdir(add_path)
for i in file:
absolute_path = os.path.join(add_path,i)#绝对路径
if os.path.isfile(absolute_path) :
print(absolute_path)
# if os.path.isfile(i):
# filepath, tempfilename = os.path.split(i) # 拆开
# filename, extension = os.path.splitext(tempfilename)# 获取扩展名
f = open(absolute_path, "a+", encoding="utf8")
f.write("test\n")
f.close()
if __name__ == '__main__':
add_text(r"F:\test",['a','b'])
# filepath, tempfilename = os.path.split(i) # 拆开
# #filename, extension = os.path.splitext(tempfilename)# 获取扩展名
# #if filename[]