添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hi all,

When I run the following code, i'm receiving just <pexpect.popen_spawn.PopenSpawn object at 0x029678F0>

What's wrong?

Thanks in advance.

import pexpect
from pexpect import popen_spawn
import sys
    co = pexpect.popen_spawn.PopenSpawn('ftp localhost',encoding="utf-8")
    co.expect("",timeout=30)
    co.logfile = sys.stdout
    co.timeout = 4
    co.expect(":")
    co.sendline("test")
    co.expect(".*word:.*")
    co.sendline("test123")
    co.sendline('dir')
    co.expect('ftp>')
    co.close()
except Exception as e:
    print(co)
          

That probably means that encoding='utf-8' is not the right option for your system or for that subprocess. What system are you on? If it's Windows, the encoding might be 'cp1252' (that's the default for western European languages, in any case).

Do you need to have the try/except to catch the exception? If there's an uncaught exception, it's automatically printed out with a traceback, which is more helpful for debugging.