假设我有一个字符串,我想在看到某些字符之前或之后删除其余的字符串
例如,我的所有字符串都包含'egg':
"have an egg please"
"my eggs are good"
Run Code Online (Sandbox Code Playgroud)
我想得到:
"egg please"
"eggs are good"
Run Code Online (Sandbox Code Playgroud)
还有同样的问题,但我怎样才能删除除字符前面的字符串之外的所有字符串?
我已经重写了两次,我看不出问题,我已经在 python 2 上安装了 mechanize,并且我没有同时执行制表符和空格,我只执行空格。
import urllib
from bs4 import BeautifulSoup
import re
import urlparse
import mechanize
url = "http://www.dailymail.co.uk/home/index.html"
br = mechanize.Browser()
br.open(url)
for link in br.links():
print link
Run Code Online (Sandbox Code Playgroud)
错误是
Traceback (most recent call last):
File "mechanize.py", line 4, in <module>
import mechanize
File "/home/ro/Autoblog/mechanize/mechanize.py", line 8, in <module>
br = mechanize.Browser()
AttributeError: 'module' object has no attribute 'Browser'
Run Code Online (Sandbox Code Playgroud) 请有人帮我这个,
我无法获得selenium点击python按钮.我在python 3.4上使用Firefox 42
浏览器打开,但就是这样
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("http://www.speedyshare.com/")
elem = find_element_by_id_name("selectfilebox")
elem.click()
Run Code Online (Sandbox Code Playgroud)
浏览器打开但我收到以下错误
Traceback (most recent call last):
File "/home/ro/sele.py", line 6, in <module>
elem = find_element_by_id_name("selectfilebox")
NameError: name 'find_element_by_id_name' is not defined
Run Code Online (Sandbox Code Playgroud)