Hỏi Đáp

Welcome!

This community is for professionals and enthusiasts of our products and services.
Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.

0

Làm sao để print aData không hiện product.id bên trong aData[product.id]

Ảnh đại diện
huongtrinh
for product in order.order_line:
       aData[product.id]= collections.OrderedDict((
                    ('productID', product.id),
                    ('product_name', product.name),
                    ('product_quanty', product.product_uom_qty),
                    ('product_price', product.price_unit),
        ))
        print aData

kết quả:
(7, OrderedDict([('productID', 7), ('product_name', u'Khuy\xean tai b\u1ea1c'), ('product_quanty', 20.0), ('product_price', 1000.0)]))

làm sao để không hiện "(7, "
Ảnh đại diện
Huỷ bỏ
3 Trả lời
0
Ảnh đại diện
Coffee One
Bài trả lời tốt nhất

Bạn có thể print aData[product.id] như bác David hướng dẫn là được

for product in order.order_line:
       aData[product.id]= collections.OrderedDict((
                    ('productID', product.id),
                    ('product_name', product.name),
                    ('product_quanty', product.product_uom_qty),
                    ('product_price', product.price_unit),
       ))
       print aData[product.id]
1 Bình luận
Ảnh đại diện
Huỷ bỏ
Ảnh đại diện
ViindooBot
-

hi all
Mình muốn lưu tất cả thông tin của vòng lặp trong OrderedDict
mình đã tìm được giải pháp rồi
thank all

0
Ảnh đại diện
huongtrinh
Bài trả lời tốt nhất

Hi anh
em muốn print aData luôn vì em cần lấy thông tin của vòng lặp đó luôn nhưng không muốn hiện cái aData[product.id]
hiện ở cái dạng collections.OrderedDict

Ảnh đại diện
Huỷ bỏ
0
Ảnh đại diện
Trần Ngọc Tuấn
Bài trả lời tốt nhất

Bạn print aData[product.id] thay vì print aData.
Đặc tính của print là in ra tất cả mà.

Ảnh đại diện
Huỷ bỏ