简体   繁体   English

如果我不使用交互式shell打开py程序,则会出现错误

[英]Py program gives an error if I dont open it with interactive shell

I 've a porgram called searchMachine.py that if I run it straight from IDLE (F5..)it works just fine, but If I run it by just clicking on searchMachine.py it works untill somepoint and then I get an error. 我有一个名为searchMachine.py的项目,如果我直接从IDLE(F5 ..)运行它,它就可以正常工作,但是如果我只单击searchMachine.py来运行它,直到某个时候它就出现了,然后出现错误。 See below. 见下文。 Thanks for any input you could give me. 感谢您能给我的任何意见。 By the way, any idea how I can make this chrome work in silent? 顺便说一句,有什么主意如何让我的Chrome保持静音? for example minimized? 例如最小化?

    from selenium import webdriver
    from selenium.webdriver.support.ui import Select

    print('Please type the machine name.')
    machinename = input()
    print('')
    print('Thank you.')
    print('')
    print('Results will show below.')
    print('')

    path_to_chromedriver = 'C:\python34\chromedriver\chromedriver.exe' # change path as needed
    browser = webdriver.Chrome(executable_path = path_to_chromedriver)
    url = 'http://app.corp'
    browser.get(url)



    browser.find_element_by_xpath("/html/body/div[4]/form/table[1]/tbody/tr/td[5]/input[1]").send_keys(machinename)

    browser.find_element_by_css_selector('input[type=\"submit\"]').click() # working to press submit

    xpath = '/html/body/div[4]/form/center[2]/table/thead'
    for i in browser.find_elements_by_xpath(xpath):
        print (i.text)
    xpath = '/html/body/div[4]/form/center[2]/table/tbody/tr'
    for i in browser.find_elements_by_xpath(xpath):
        print (i.text)

    browser.close() 

import os
os.system("c:/code/close_chrome_driver.bat")

error is: 错误是:

在此处输入图片说明

The error occurs because the unicode character or U+25BE BLACK DOWN-POINTING SMALL TRIANGLE cannot be written into Windows console window, as it does not have a match in the CP850 character set as used by your Windows console. 错误发生,因为Unicode字符U+25BE BLACK DOWN-POINTING SMALL TRIANGLE不能被写入Windows控制台窗口,因为它并没有在比赛CP850字符13759 您的 Windows控制台设置。

Now, Python croaks loudly when it cannot print the correct value. 现在,当无法打印正确的值时,Python大声嘶哑。 You could set the PYTHONIOENCODING environment variable to say cp850:ignore which would make the Python process ignore errors; 您可以将PYTHONIOENCODING环境变量设置为cp850:ignore ,这将使Python进程忽略错误。 or you can print to stderr instead of stdout , which would use the backslashescape error handling. 或者您可以打印到stderr而不是stdout ,这将使用backslashescape错误处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我用什么打开 .PY 程序? - What do I open a .PY program with? 我正在使用 ubuntu,django 3.0.5,sqlte3 ...帮助,:谢谢! 在命令行中运行“python manage.py shell”,它会给出错误: - I'm using ubuntu, django 3.0.5, sqlte3 …Help!!! Thanks! running “python manage.py shell” in command line, it gives error: 我已经安装了 textblob,当我在 py 解释器上单独导入它时它可以工作,但是我运行的程序它给出了模块未找到错误 - I have installed textblob and it works when I import it separately on py interpretor but what I run program it gives module not found error 加载.py文件并显示IPython交互式外壳 - Load the .py file and display IPython interactive shell Python Shell已打开但没有.py文件? - Python shell is open but not .py file? 如何使用python启动交互式shell程序? - How to use python to start an interactive shell program? python:从程序运行交互式python shell - python: run interactive python shell from program 如何在 Visual Studio Code 1.44.2 中打开交互式 shell/REPL? - How do I open the interactive shell/REPL in Visual Studio Code 1.44.2? 如何打开倍数.py程序 - How to open a multiples .py program 当我尝试安装 discord.py 时,它给了我错误 - when i try to install discord.py it gives me error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM