如何将整个循环压缩为一行。有什么办法吗?
var settings = {
/* Appearance */
headerTag: "h1",
bodyTag: "div",
contentContainerTag: "div",
actionContainerTag: "div",
stepsContainerTag: "div",
cssClass: "wizard",
stepsOrientation: $.fn.steps.stepsOrientation.horizontal,
/* Templates */
titleTemplate: '<span class="number">#index#.</span> #title#',
loadingTemplate: '<span class="spinner"></span> #text#',
/* Behaviour */
autoFocus: false,
enableAllSteps: true,
enableKeyNavigation: true,
enablePagination: true,
suppressPaginationOnFocus: true,
enableContentCache: true,
enableCancelButton: false,
enableFinishButton: true,
preloadContent: false,
showFinishButtonAlways: false,
forceMoveForward: false,
saveState: false,
startIndex: 0,
/* Transition Effects */
transitionEffect: $.fn.steps.transitionEffect.none,
transitionEffectSpeed: 200,
答案 0 :(得分:1)
from itertools import product
aa = [x*y for x,y in product(args, args) if x != y]
答案 1 :(得分:1)
以前的答案绝对没有错。双循环也可以,并且可能更容易理解。
[x * y for x in args for y in args if x != y]