[root@max ~]vim test.py
import os,sys
for i in range(10):
f=file('/test/file%s'%i,'w')
continue ——for循环批量创建文件
os.system('find /test/ -name file* > test.txt') ——调用系统命令查找重定向
p=open('test.txt','r').readlines() ——读取文件中所有内容,并定变量
f=open('test_new.txt','w+')
for line in p:
f.write('max'+line.strip()+'@123.com'+'\n') ——for循环编写新建文件
[root@max test]# ls
file0 file1 file2 file3 file4 file5 file6 file7 file8 file9
[root@max ~]# cat test.txt
/test/file1
/test/file6
/test/file2
/test/file7
/test/file5
/test/file0
/test/file4
/test/file3
/test/file8
/test/file9
[root@max ~]# cat test_new.txt
max/test/file1@123.com
max/test/file6@123.com
max/test/file2@123.com
max/test/file7@123.com
max/test/file5@123.com
max/test/file0@123.com
max/test/file4@123.com
max/test/file3@123.com
max/test/file8@123.com
max/test/file9@123.com