python 在使用 pexpect 的时候,报了
module 'pexpect' has no attribute 'spawn'
并不是”pexpect”没有“spanwn”模块,点进去看 pexpect 的源代码:
import sys
PY3 = (sys.version_info[0] >= 3)
from .exceptions import ExceptionPexpect, EOF, TIMEOUT
from .utils import split_command_line, which, is_executable_file
from .expect import Expecter, searcher_re, searcher_string
if sys.platform != 'win32':
# On Unix, these are available at the top level for backwards compatibility
from .pty_spawn import spawn, spawnu
from .run import run, runu
__version__ = '4.0.1'
__revision__ = ''
__all__ = ['ExceptionPexpect', 'EOF', 'TIMEOUT', 'spawn', 'spawnu', 'run', 'runu',
'which', 'split_command_line', '__version__', '__revision__']
发现该函数不能在 windows 系统下运行,换 linux 系统即可。
来源:CSDN
作者:whatday
链接:https://blog.csdn.net/whatday/article/details/103568211