下载 GitHUb AS400 Interface, 并 install comtypes package
# python -m pip install comtypes
from ibmpcomm import Instancedef main():wSession = Instance(session='A')GotoCmdEntry(wSession)wSession.set_text(text='Dspjob',row=18,column=7)wSession.send_keys(key='[Enter]')wSession.wait(1)wjobname = wSession.get_text(row=3,column=9,length=10).decode('UTF-8')print('job is ',wjobname)wSession.send_keys(key='[pf12]')def GotoCmdEntry(wSession):wstr = wSession.get_text(row=1,column=34,length=13).decode('UTF-8')i = 0while True:if i > 20 : breakif wstr == 'Command Entry': breakwstr1 = wSession.get_text(row=1,column=1,length=80).decode('UTF-8')if wstr1.find('Exit Interactive SQL') > 0: wSession.send_keys(key='[Enter]')wSession.send_keys(key='[pf12]')i += 1wstr = wSession.get_text(row=1, column=34, length=13).decode('UTF-8')wSession.send_keys(key='[reset]')wSession.send_keys(key='[sys attn]')wSession.wait(1)if __name__ == '__main__':main()