【发布时间】:2022-01-11 19:17:31
【问题描述】:
我有以下代码在 linux 中使用 pexpect 没问题。
import pexpect
child = pexpect.spawn('ssh test@ip' % (susername, ip) , encoding='utf-8')
child.logfile = open("{}/{}.txt".format(folder, ip),"w")
尝试更改为 wexpect 以在 windows 中使用但日志文件为空时 我的目标是将 wexpect 产生的所有内容从头到尾写入日志文件
我试过了
import wexpect
logging =""
child = wexpect.spawn('ssh -c aes256-cbc %s@%s' % (username, ip) , encoding='utf-8' , logfile=logging)
print(logging)
child.logfile = open("{}/{}.txt".format(folder, ip),"w")
但 print 也是空的。
所有其他wexpect 函数似乎都工作正常,我可以使用.sendline、.expect 函数。
检查是否有人知道如何让日志记录工作 似乎没有很多文档
【问题讨论】:
标签: python python-3.x pexpect wexpect