我正在编写一个程序,它将在网站上搜索文章中的特定条目,我正在使用selenium webdriver for Python.
在尝试连接到网站时,我遇到了以下异常:
Traceback (most
recent call last):
File "search.py", line 26, in <module>
test.search_for_keywords()
File "search.py", line 13, in search_for_keywords
browser = webdriver.Firefox()
File "C:\Python27\lib\site-packages\selenium-3.0.0b2-py2.7.egg\selenium\webdriver\firefox\webdriver.py", line 65, in __init__
self.service.start()
File "C:\Python27\lib\site-packages\selenium-3.0.0b2-py2.7.egg\selenium\webdriver\common\service.py", line 86, in start
self.assert_process_still_running()
File "C:\Python27\lib\site-packages\selenium-3.0.0b2-py2.7.egg\selenium\webdriver\common\service.py", line 99, in assert_process_still_running
% (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service geckodriver unexpectedly exited. Status code was: 2
Run Code Online (Sandbox Code Playgroud)
它说网络驱动程序意外退出.我该如何解决这个问题?我正在尝试使用python版本2.7.12与firefox版本48.0连接
我有一个程序可以为我创建工作笔记,它有效,但是有一个我想摆脱的尾随破折号:
def prompt(input)
print "[#{Time.now.strftime('%T')}] #{input}: "
STDIN.gets.chomp
end
def work_performed
count = 0
notes = ''
while true
input = prompt("Enter work notes[#{count += 1}]")
notes << "\n" + "#{input}\n"
if input.empty?
return notes
else
while input.empty? != true
input = prompt('Enter work notes[*]')
notes << " - #{input}\n"
end
end
end
end
Run Code Online (Sandbox Code Playgroud)
运行时:
test
- tset
-
test
- tset
-
tset
- tset
-
Run Code Online (Sandbox Code Playgroud)
我怎样才能重构这个以消除关卡末端的尾随破折号?