我想在List Comprehensions上插入一个插件。 我能做到?
t = ['test','tes']
x = ['1','2','3','4','5']
t.insert([0,i]for i in x)
答案 0 :(得分:1)
如果你要找的结果是这样的
define(['plugins/router', 'durandal/app', 'gcharts', 'jquery'], function (router, app, gcharts, $) {
var projectStatsModel = function (data) {
this.projectId = data.projectId;
this.projectName = data.projectName;
this.projectDescription = data.projectDescription;
this.projectPlatform = data.projectPlatform;
this.projectPointsLabel = "Total Points: " + data.projectNumPoints;
this.projectStoriesLabel = "Total Stories: " + data.projectNumStories;
this.projectCreatedDateLabel = "Created " + data.projectCreationDate;
this.projectUpdateDateLabel = "Last Updated " + data.projectModifyDate;
this.projectEpics = data.projectEpics;
this.projectStories = data.projectStories;
return this;
}
var ctor = function () {
function drawPage(data) {
var model = projectStatsModel(data);
ko.applyBindings(model);
}
function loadData() {
var projectId = router.activeInstruction().params[0];
$.ajax({
url: '/ClubhouseData/GetProjectDetails',
data: {
'projectId': projectId
},
type: 'GET',
cache: 'false',
success: function (result) {
console.log(result);
drawPage(result);
}
});
}
ctor.prototype.activate = function () {
loadData();
}
};
return ctor;
});
代码如下:
['test', 'tes', [0, 'test'], [0, 'tes']]
答案 1 :(得分:1)
你可以在列表理解中完成它但最终会做额外的工作。只需在for循环中执行:
for thing in x:
t.insert(0, thing)
答案 2 :(得分:0)
t = ['test','tes']
x = ['1','2','3','4','5']
out = t + x
你的输出将是['tes','test','1','2','3','4','5','6'] 或者那些单独的东西。 python允许你连接字符串
答案 3 :(得分:0)
ListItemLabel只接受字符串。我想在列表中给它多个元素,我在ListItemLabel前面str中使用它,但是它没有做任何事情。
我不知道你的思维方式是否正确
的Python:
result_true = ListProperty([])
extra = self.viewedit.adapter.data
for edit in extra:
if edit['active'] == True:
app.result_true.append(edit['text'])
#app.result_true = (edit['text'])
print app.result_true
Kivy:
ListItemLabel:
text:str(ctx.edit)
返回:
[' \ XCE \ XBB \ XCE \ xb9 \ XCE \ XB1 \ XCF \ X83 \ XCF \ X84 \ XCE \ XAE \ XCE \ XBD \ XCF \ X84 \ XCE \ XBF \ XCE \ XBC \ XCE \ XAC \ XCF \ X84 \ XCE \ XB1&#39 ;, ' \ XCF \ X83 \ XCE \ XBF \ XCF \ X85 \ XCF \ X83 \ XCE \ XAC \ XCE \ XBC \ XCE \ xb9&#39 ;, ' \ XCF \ X84 \ XCF \ X85 \ XCF \ X81 \ XCE \ XAF']