我正在学习python(2.7).我了解到我们可以使用以下方法将字符串和变量放在一起打印:
x = "Hello"
y = "World"
Run Code Online (Sandbox Code Playgroud)
使用逗号:
print "I am printing" , x, y # I know that using comma gives automatic space
Run Code Online (Sandbox Code Playgroud)
通过使用串联:
print "I am printing" + " " + x + " " + y
Run Code Online (Sandbox Code Playgroud)
通过使用字符串格式化器
print "I am printing %s %s" % (x, y)
Run Code Online (Sandbox Code Playgroud)
在这种情况下,所有三个打印相同:
I am printing Hello World
Run Code Online (Sandbox Code Playgroud)
这三者之间有什么区别,是否存在一个优先于另一个的特定情况?
我设计了这个注册表单。问题是两行之间的空间太大,即 id 和密码部分。如何减少空间?
CSS(HTML/Head/Style 元素内部)
<html>
<head>
<title>Signup</title>
<style>
div
{
position:absolute;
top:300px;
left:550px;
width:200px;
}
table
{
height:150px;
border:1px solid black;
border-radius:10px;
box-shadow:0px 0px 2px #777;
}
td
{
padding:10px;
}
.ip
{
border-radius:5px;
border:1px solid grey;
}
.label
{
color:#EE6AA7;
font-family:Helvetica;
font-size:17px;
}
</style>
</head>
Run Code Online (Sandbox Code Playgroud)
HTML(HTML/正文内部)
<body>
<div>
<form>
<table>
<tr>
<td class="label">Id</td>
<td><input type="text" name="id" class="ip"></td>
</tr>
<tr>
<td class="label">Password</td>
<td><input type="text" name="pswrd" class="ip"></td>
</tr>
</table>
</form>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 当我输入man robocopypowershell时,它显示:
Get-Help:Get-Help在此会话的帮助文件中找不到robocopy.要下载更新的帮助主题,请键入:"Update-Help".
我Update-Help作为管理员在powershell中运行,它下载了不同模块的帮助.但它仍然显示相同的错误man robocopy.
它适用于其他命令 man dir
在解决代码战中的kata时,我遇到了将二进制数(以列表形式)转换为整数的问题的单行解决方案.我无法理解人们使用java stream api reduce函数的解决方案.请帮我理解.
例如:[0,0,0,1]被视为0001,它是1的二进制表示.
import java.util.List;
public class BinaryArrayToNumber {
public static int ConvertBinaryArrayToInt(List<Integer> binary) {
return binary.stream().reduce((x, y) -> x * 2 + y).get();
}
}
Run Code Online (Sandbox Code Playgroud)