使用python模块py3270的AttributeError

2024-04-29 09:20:17 发布

您现在位置:Python中文网/ 问答频道 /正文

作为一些自动化的一部分,我尝试使用python连接到大型机,在那里我可以访问大型机文件并创建一个 报告。就像使用大型机文件作为DB for python程序一样。在

要登录到大型机-我们需要提供主机详细信息(xyz.host.com网站) 接着是地区详情(h123p),然后是我们的证书。在

我发现我们可以使用python包py3270来实现这一点,并尝试这样做,但是得到了错误。在

from py3270 import Emulator

# or not (uses s3270)
em = Emulator()

em.connect('xyx.example.com')
em.fill_field(3, 1, 'xxxx',5)
em.send_enter()
em.fill_field(2, 1, 'xxxxxxx', 7)
em.send_enter()
em.fill_field(8, 20, 'xxxxxxxx', 8)
em.send_enter()

# if your host unlocks the keyboard before truly being ready you can use:
em.wait_for_field()

# maybe look for a status message
if not em.string_found(1, 2, 'login succesful'):
abort()

# do something useful

# disconnect from host and kill subprocess
em.terminate()

错误:

^{pr2}$

Tags: 文件fromcomsendhostfieldfor错误
1条回答
网友
1楼 · 发布于 2024-04-29 09:20:17

根据您看到的错误消息,我怀疑您在缺少/未找到x3270/s3270库方面遇到了问题。在

return Ws3270App(args)
File "C:\Program Files (x86)\Python37-32\lib\site-packages\py3270   
\__init__.py", line 140, in __init__
self.spawn_app()
File "C:\Program Files (x86)\Python37-32\lib\site-packages\py3270  
\__init__.py", line 145, in spawn_app
args, stdin=subprocess.PIPE, stdout=subprocess.PIPE,   
stderr=subprocess.PIPE
File "C:\Program Files (x86)\Python37-32\lib\subprocess.py", line 775,   
in __init__
restore_signals, start_new_session)
File "C:\Program Files (x86)\Python37-32\lib\subprocess.py", line 1178,  
in _execute_child
startupinfo)

上述情况表明库正在尝试启动Ws3270,即x3270的windows版本,但无法启动。在

确保所需的库在您的路径中并且在python中可见。在

相关问题 更多 >