在python中写入文件

时间:2016-03-24 17:42:02

标签: python debian

我试图在python中创建一个命令,通过写入〜/ .bashrc来创建新的别名,我的代码如下:

new_alias = raw_input("Choose alias name > ")
alias_command = raw_input("Write alias command > ")

with open("/test/text","r") as f2:
    with open("text","w+") as f1:
            f1.write(new_alias + alias_command)
            f1.seek(0,0)
            command = f1.read()

但是当我打开文本文件时,里面没有写任何内容,所以我的问题是我在这个文件中做错了什么?

0 个答案:

没有答案