展开全部
#python
f=open('f.txt','w') # r只读,w可写,a追加2113
for i in range(0,10):f.write(str(i)+'\n')
例子:
#!/usr/bin/python
#coding=utf-8
import os
import time
import sys
f=open('a.txt','a')
f.write(os.popen('netstat -nltp | grep 22').read())
f.close()
扩展资料:5261
关于上述创建文件,4102文件内1653容追加
#python
import random
f=open('f.txt','a')
for i in range(0,10):f.write(str(random.randint(0,9)))
. . .
f.write('\n')
f.close()
或者
#python
import rando
f=open('f.txt','a')
for i in range(0,10):
for i in range(0,10):f.write(str(random.randint(0,9)))
f.write('\n')
f.close()