我試圖編寫一個程序,運行一些shell命令與模擬用戶數據。Python pexpect沒有按預期工作
的問題是shell命令不正確沒有這一行代碼的末尾運行:
raw_input('press <enter> to exit')
我怎麼能擺脫線的?
child = pexpect.spawn('grunt init:gruntfile')
child.logfile_read = sys.stdout
child.expect ('Is the DOM involved in ANY way?')
child.sendline ('y')
child.logfile_read = sys.stdout
child.expect ('Will files be concatenated or minified?')
child.sendline ('y')
child.logfile_read = sys.stdout
child.expect ('Will you have a package.json file?')
child.sendline ('y')
child.logfile_read = sys.stdout
child.expect ('Do you need to make any changes to the above before continuing?')
child.sendline ('n')
child.logfile_read = sys.stdout
raw_input('press <enter> to exit')
這是一個笑話的標題;-) – puk