-1
我写在Django的项目。 我正在将具有数量和天数的出租产品添加到我的购物车中。字符串和整数转换
这里是我的代码。那些代码在“addToCart.py”
pid=request.urlparams[0] #pid is a product id
cart = request.session.get('cart',{}) #create a cart
cart2[pid]= [days,quantity] # days, quantity are sent in using forms
在“CheckOut.py”下的那些代码。现在我想计算总数。
product = product.objects.get(id=pid) # get the product
quantity=int(cart2[(str(pid)][1]) # this does not work. I need some help about how to do int and string coversion
total=product.Price*quantity*int(cart2[(str(pid)][0]) # this does not neither.
你是什么意思由它不工作。获取任何异常消息? –
'这不起作用.'不是一个有效的问题。那它不起作用呢?你期望发生什么?究竟发生了什么?什么是输入?你是否收到错误?如果是这样,那是什么?请提供完整的追溯。 – That1Guy
括号不匹配 – sshashank124