作为循环练习的一部分,我应该编写一个读取两个整数X和Y的程序。作为输出,程序打印从1到Y的所有整数,以X数字的方式组织出现在每一行。
所以我应该在某个地方使用while
或for
。到目前为止我所拥有的是:
代码:
n_per_line = int(input('Numbers per line: '))
upperbound = int(input('Upper bound: '))
i = 1
n = 1
while i <= upperbound:
while n <= n_per_line:
print(i, end=' ')
n += 1
i += 1
但是,这只打印出一行输出。例如,
Numbers per line: 3
Upper bound: 4
gives 1 2 3 in a single line. And
Numbers per line: 2
Upper bound: 4
gives 1 2 in a single line.
答案 0 :(得分:1)
您需要为新行添加打印件
/(?:addClass[(]*|class=)["']([a-zA-Z0-9_-]+)["'][)]*/gi;
答案 1 :(得分:0)
public WebDriver getDriver()
{
if (driver == null)
{
try
{
if (Environment.getProperty("appBrowser").equalsIgnoreCase("headless"))
{
driver = new HtmlUnitDriver(BrowserVersion.CHROME, true);
Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(Level.OFF);
}
else
{
System.setProperty("webdriver.chrome.driver",
"./src/test/resources/common/chromedriver.exe");
driver = new ChromeDriver();
}
}
catch (FileNotFoundException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
catch (IOException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
try
{
driver.get(Environment.getProperty("appURL"));
}
catch (FileNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
driver.manage().window().maximize();
}
return driver;
}