如何进行for
循环或列表理解,以便每次迭代都给出两个元素?
l = [1,2,3,4,5,6]
for i,k in ???:
print str(i), '+', str(k), '=', str(i+k)
Run Code Online (Sandbox Code Playgroud)
输出:
1+2=3
3+4=7
5+6=11
Run Code Online (Sandbox Code Playgroud) 我知道没有直接的方法,但仍然..我们可以将XElement
元素转换为XmlNode
.类似的选项InnerText
,并InnerXml
有 XmlNode
具体的.
所以,如果我想使用这些选项,可以做什么来转换 XElement
成XmlNode
反之亦然.
首先,我是WPF的新手.
我有这种风格为我的物品做好准备:
<Style x:Key="lvItemHover" TargetType="{x:Type ListViewItem}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Foreground" Value="Black" />
</Trigger>
</Style.Triggers>
</Style>
Run Code Online (Sandbox Code Playgroud)
如何将这种风格赋予我的物品ListView
?
嗨我已经安装了Soap UI ...像C,Java一样,我们将创建一些示例程序.同样我想使用一些示例请求和响应..如何创建一个没有wsdl的请求和响应?
在我看来,我有一个下拉列表,我通过Ajax调用填写.此下拉列表在表单内.但是在提交时,我没有在formCollection中看到这个控件.
还有一件事,或者当我尝试添加Html.DropDownList("AccountId")时,我得到错误 - 没有类型为'IEnumerable'的ViewData项具有键'AccountId'.
列出我的视图和控制器代码......
- 视图 -
using (Html.BeginForm("GetNames", "Account", FormMethod.Post, new { id = "accountParameters" }))
{
....
....
<select id="AccountId" runat="server"></select> //This is not available in formcollection
//Html.DropDownList("AccountId"); //This throws exception
@:<p><input type='submit' value='Submit'/></p>
}
...
...
<script>
$(document).ready(function () {
$.ajax({
url: '/Account/GetAccounts',
type: "GET",
success: function (result) {
for (i = 0; i < result.length; i++) {
$('#AccountId').append($('<option></option>').val(result[i].accountId).html(result[i].name));
}
}
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
- 控制器 -
public ActionResult GetAccounts(string id)
{
return Json(GetAccounts(), JsonRequestBehavior.AllowGet);
} …
Run Code Online (Sandbox Code Playgroud) 例如,我有字符串/wiki/File:test.JPG
我应该检查它是否有一个扩展"jpeg","jpg","png","gif"
目前我已经写过它link.search(/.[j,p,g][p,i,n][e,g,f][g]?/gi)
并且它是有效的,但我想要更好的正则表达式.