qq489498494 发表于 2018-8-8 06:11:22

python操作文件写入内容

# cat file.py  
#/usr/bin/env python
  
# coding: utf-8
  
ecs="efwefwffrfrer"
  
ipaddrr="192.168.56.10"
  
print type(ecs+ " "+ipaddrr+" has stopeed")
  
def write_result(str):
  
    writeresult=file(r'/tmp/ecs.log','a+')
  
    str1=writeresult.write(str+'\n')
  
    writeresult.close()
  
    return str
  
if __name__ == "__main__":
  
    write_result(ecs+ " "+ipaddrr+" has stopeed")
  
#
页: [1]
查看完整版本: python操作文件写入内容