ITPub博客

首页 > IT职业 > IT图书 > python操作文件写入内容

python操作文件写入内容

IT图书 作者:lanyu 时间:2021-09-09 09:22:11 0 删除 编辑

[root@bogon ~]# 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")

[root@bogon ~]#


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2035/viewspace-2802744/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-07-29

  • 博文量
    96
  • 访问量
    7364