我有一个样本表
table
(2+2)
(2+4)
(2+6)
(4+2)
(4+4)
(4+6)
(6+2)
(6+4)
(6+6)
我想以这种方式将每个值添加到其他每个值:
table
4
6
8
6
8
10
8
10
12
最终结果如下:
lst = [1, 3, 2, 2, 4]
exists = []
total = 0
for nb in lst:
# if nb is even AND has not been used yet...
if nb % 2 == 0 and nb not in exists:
total += nb
# check the nb as used.
exists.append(nb)
但我不知道如何以这种方式计算所有值。
答案 0 :(得分:3)
自我class ModelName(models.Model):
sthree = S3BotoStorage()
def file_name(self,filename):
ext = filename.split('.')[-1]
name = "%s/%s.%s" % ("downloads", uuid.uuid4(), ext)
return name
upload_file = models.FileField(upload_to=file_name,storage = sthree)
def save(self):
self.upload_file.storage.headers = {'Content-Disposition': 'attachments; filename="%s"' %self.upload_file.name}
super(ModelName, self).save()
获得交叉产品:
CROSS JOIN
如果您需要保证特定订单,请添加select t1.c + t2.c
from tablename t1 cross join tablename t2
:
ORDER BY