可能重复:
如何在Python中将列表拆分为大小均匀的块?
python:将"5,4,2,4,1,0"转换为[[5,4],[2,4],[1,0]]
[1,2,3,4,5,6,7,8,9]
Run Code Online (Sandbox Code Playgroud)
- >
[[1,2,3],[4,5,6],[7,8,9]]
Run Code Online (Sandbox Code Playgroud)
是否有简单的方法来做到这一点,没有明确的'for'?
我正在使用DotLiquid模板引擎并尝试在模板中访问字典值.我已经传递给模板这个drop:
public class SomeDrop : Drop
{
public Dictionary<string, object> MyDictionary {get; set;}
}
var someDropInstance = SomeDrop
{
MyDictionary = new Dictionary<string, object> {{"myKey", 1}}
}
Template.NamingConvention = new CSharpNamingConvention();
var preparedTemplate = Template.Parse(template);
var templateOutput = preparedTemplate.Render(Hash.FromAnonymousObject(new { @this = someDropInstance }));
Run Code Online (Sandbox Code Playgroud)
在模板我不能访问的myKey值
{{ this.MyDictionary.myKey }}
既不
{{ this.MyDictionary['myKey'] }}
如何在这个类的每个子类策略的新NHibernate Mapping-By-Code中编写映射:
public class Person
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
}
public class JuridicalPerson : Person
{
public virtual int Id { get; set; }
public virtual string LegalName { get; set; }
}
public class PrivatePerson : Person
{
public virtual int Id { get; set; }
public virtual bool Sex { get; set; }
}
Run Code Online (Sandbox Code Playgroud) nhibernate inheritance nhibernate-mapping nhibernate-mapping-by-code