2024-04-26 00:43:26 发布
网友
所以在一个fab任务中,我试图在服务器上保存一个文件,而不是在我的笔记本电脑上。 所以这节省了文件.txt我想把它保存在服务器的/tmp上
with open('/tmp/file.txt', 'a') as f: f.writelines("\n".join(names)) f.write('\n')
你可以append
或者只是像这样使用run
for name in names: command = "echo {} >> /tmp/file.txt".format(name) run(command)
您可以使用^{}命令。它将文件上载到远程主机。在
from fabric.context_managers import cd from fabric.operations import put with cd('/path/in/remote/host/'): put('/path/to/local/file.txt', 'file.txt')
你可以append
或者只是像这样使用run
您可以使用^{} 命令。它将文件上载到远程主机。在
相关问题 更多 >
编程相关推荐