python 读写文件

#! -*- encoding:utf-8 -*-
import os
from config import *
from function import GetCsspToken, RegistInCssp, GetCsspStatus

if __name__=='__main__':
    token = GetCsspToken(email, mypasswd)
    if os.path.isfile("./status.txt"):
        os.remove("./status.txt")
    fp = open("./status.txt","w")
    statuses = GetCsspStatus(token)
    i = 0
    for status in statuses:
        i = i + 1
        print("%5d %20s %15s %15s %16s %30s %8s"%(i, status['hostName'],status['primaryIp'],status['securityStatus'],status['status'],status['systemOwnerEmail'],status['id']))
        fp.writelines(["%5d %20s %15s %15s %16s %30s %8s"%(i, status['hostName'],status['primaryIp'],status['securityStatus'],status['status'],status['systemOwnerEmail'],status['id'])])
        fp.write('\n')
    fp.close()

  

posted @ 2016-06-16 13:44  juandx  阅读(165)  评论(0编辑  收藏  举报