我正在搜索文本"奶酪!" 在谷歌主页上,不确定如何在按下搜索按钮后点击搜索到的链接.例如,我想在搜索页面上单击顶部的第三个链接,然后如何找到标识链接并单击它.我的代码到目前为止:
package mypackage;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.WebDriverWait;
public class myclass {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\selenium-java-2.35.0\\chromedriver_win32_2.2\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");
WebElement element = driver.findElement(By.name("q"));
element.sendKeys("Cheese!");
element.submit();
//driver.close();
}
}
Run Code Online (Sandbox Code Playgroud) 这是 udacity.com 网络开发课程,他们要求编写一个有效年份的程序,1900 年到 2020 年之间的任何年份都是有效年份...现在,当我提交以下代码时,它给出了此错误:
“不正确。您的提交未返回输入“1920”的正确结果。您的提交通过了 9 个测试用例中的 7 个。”
我的功能:
def valid_year(year):
if year and year.isdigit():
if int(year) >=1900 and int(year) <=2020:
return year
print valid_year('1970')
Run Code Online (Sandbox Code Playgroud)
为什么1920年不起作用?udacity 的相同功能运行良好......有人请告诉我这两个代码有什么区别
优达学城功能:
def valid_year(year):
if year and year.isdigit():
year = int(year)
if year >=1900 and year <=2020:
return year
print valid_year('1970')
Run Code Online (Sandbox Code Playgroud) 我正在寻找一种在 Plotly 散点图中绘制两条水平线的方法。我的x轴索引不是固定的并且每次都在变化。所以我正在寻找 y = 5 和 y = 18 处水平穿过图表的水平线
我在这里寻找解决方案,但我不确定如何使用 Plotly Express 的布局
我的散点图代码:
import plotly.express as px
df = pd.DataFrame({"x":[0, 1, 2, 3, 4,6,8,10,12,15,18], "y":[0, 1, 4, 9, 16,13,14,18,19,5,12]})
fig = px.scatter(df, x="x", y="y")
fig
Run Code Online (Sandbox Code Playgroud) 我正在尝试将数学字符串拆分为数学运算符.例如
String = 7*6+3/2-5*6+(7-2)*5
String1 = ["7","*","6","+","3","/","2","-","5","*","6"]
Run Code Online (Sandbox Code Playgroud)
我试着在这里找到解决方案,这就是我得到的
String1=String.split("(?<=[-+*/])|(?=[-+*/]"),但看起来这不是为String1获取所需的结果.