第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

對(duì)象列表中轉(zhuǎn)換的 QuerySet 數(shù)據(jù)轉(zhuǎn)換為 Tuple 中的 str/int 值

對(duì)象列表中轉(zhuǎn)換的 QuerySet 數(shù)據(jù)轉(zhuǎn)換為 Tuple 中的 str/int 值

瀟湘沐 2023-08-03 17:10:39
我在非常簡單的操作中遇到了非常奇怪的問題。models.pyNbProducts(models.Model):    brand = models.CharField(max_length=45, blank=True, null=True)    name = models.CharField(max_length=45, blank=True, null=True)    cluster = models.CharField(max_length=45, blank=True, null=True)    target_market = models.CharField(max_length=10, blank=True, null=True)    cpu_vendor = models.CharField(max_length=45, blank=True, null=True)    base_platform = models.CharField(max_length=45, blank=True, null=True)    gpu_list = models.CharField(max_length=45, blank=True, null=True)    screen_size = models.CharField(max_length=45, blank=True, null=True)    screen_resulution_list = models.CharField(max_length=45, blank=True, null=True)    touchscreen = models.CharField(max_length=45, blank=True, null=True)views.py    list_Products = NbProducts.objects.\                    filter(id__in=products_for_execute).\                    values('brand', 'name', 'id')# list_Products:#<QuerySet [{'brand': 'Acer', 'name': 'Aspire R7-372T', 'id': 2713}, #{'brand': 'Acer', 'name': 'Aspire S7-393', 'id': 2716}, #{'brand': 'Acer', 'name': 'Swift SF514-51', 'id': 2743},....    class FProducts(object):        def __init__(self, id, brand, name):            self.id = str(id),            self.brand = str(brand),            self.name = str(name)           print(self.id, self.brand, self.name)        fproducts = list()    for i in list(list_Products):        fproducts.append(FProducts(id=i['id'], brand=i['brand'], name=i['name']))>> {'2713',) ('Acer',) 'Aspire R7-372T'>> {'2716',) ('Acer',) 'Aspire S7-393'>> {'2743',) ('Acer',) 'Swift SF514-51'所以。沒有任何命令,它會(huì)將兩個(gè)參數(shù) - 'id' 和 'brand' 放入元組中。參數(shù)“名稱” - 好吧,只是字符串。我不t need Tuple. And I don明白有什么關(guān)系。另外我把這個(gè)放進(jìn)去。  self.id = self.id[0]  self.brand = self.brand[0]好的,有幫助,應(yīng)用程序可以工作。但我看不到問題的根源。這是Python(3.7)還是Django(2.1.7)的問題?
查看完整描述

1 回答

?
茅侃侃

TA貢獻(xiàn)1842條經(jīng)驗(yàn) 獲得超21個(gè)贊

您自己在這里創(chuàng)建了一個(gè)元組:

        self.id = str(id),
        self.brand = str(brand),
        self.name = str(name)

應(yīng)該:

        self.id = str(id)
        self.brand = str(brand)
        self.name = str(name)


查看完整回答
反對(duì) 回復(fù) 2023-08-03
  • 1 回答
  • 0 關(guān)注
  • 159 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)