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