os 模块

#把末尾是偶数的文件夹中,创建一个a.txt,往里面随便写点东西
import os
res=os.listdir(r'd:\nhy123')
for i in res:
s1=int(i[-1])
if s1%2==0:
abs_path=r'd:\nhy123\test%s\a.txt'%s1
with open(abs_path,'w',encoding='utf-8') as f:
f.write("1233")

 

print(os.path.isdir('.'))#判断是否是文件夹

 

 



posted on 2018-08-19 23:06  smileBB  阅读(101)  评论(0编辑  收藏  举报