Python 将输出导出到记事本

Python 将输出导出到记事本,python,python-2.7,file,Python,Python 2.7,File,我正在尝试用Python 2.6.6创建一个文件。它在Python2.7中工作 fp = open('command_file.txt', 'w') fp.write(device1 + '#' + intstatus + '\n' + device1 + '#\n') 在Python 2.6.6中运行时,未创建命令_file.txt 知道如何修复它吗?是'device1'和'intstatus'字符串吗?此外,您可能会发现关闭该文件是值得注意的 fp.write(string(device1

我正在尝试用Python 2.6.6创建一个文件。它在Python2.7中工作

fp = open('command_file.txt', 'w')
fp.write(device1 + '#' + intstatus + '\n' + device1 + '#\n')
在Python 2.6.6中运行时,未创建命令_file.txt


知道如何修复它吗?

是'device1'和'intstatus'字符串吗?此外,您可能会发现关闭该文件是值得注意的

fp.write(string(device1) + '#' + string(intstatus) + '\n' + string(device1) + '#\n')
fp.close()

该文件几乎肯定正在创建中,但可能是在与您查看的目录不同的目录中创建的?我登录到root…我没有看到该文件…我尝试了10:57:03 35;查找-name command_file.txt…看不到文件..我看不到文件…不知道它是否正在创建,如果是,那么它在哪里?检查python脚本所在的文件夹