# 创建一个txt文件,文件名为name,并向文件写入msg
import os
def text_create(name, msg):
desktop_path = "C:/Users/ypj/Desktop/txt/" # 新创建的txt文件的存放路径
# full_path = desktop_path + name + '.txt' # 也可以创建一个.doc的word文档
full_path = desktop_path + name
file = open(full_path, 'w')
file.write(msg)
file.close()
# text_create('mytxtfile', 'Hello world!')
# 调用函数创建一个名为mytxtfile的.txt文件,并向其写入Hello world!
file_list = os.listdir("C:/Users/ypj/Desktop/10")
for f1 in file_list:
f2 = f1.replace('bmp', 'txt')
text_create(f2, '其他 ')
print(f2)