python - assign a value of dictionary's key into a variable -
i have following code in python:
def buildxmlupdate(dfrom, roomid, ldays): start_date_sard.text = dfrom roomid = str(roomid) room_id_sard.text = roomid ldays = {'avail': str(), 'price': str()} availability_in_data.text = ldays['avail'] price_in_data.text = ldays['price'] n in ldays: print (dfrom, roomid, ldays)
now when running
buildxmlupdate ('21/12/2015', 1, [{'avail': 1, 'price': 100}, {'avail': 3, 'price': 120}])
i following output
('21/12/2015', '1', {'avail': '', 'price': ''}) ('21/12/2015', '1', {'avail': '', 'price': ''})
in other words:
('21/12/2015', '1', {'avail': 1, 'price': 100}) ('21/12/2015', '1', {'avail': 3, 'price': 120})
as see here, dictionary avail
, price
keys set empty string want set them according ldays
arguments in method.
what doing wrong?
solved:
def buildxmlupdate(dfrom, roomid, ldays): start_date_sard.text = dfrom roomid = str(roomid) room_id_sard.text = roomid #ldays = {'avail': str(), 'price': str()} #availability_in_data.text = ldays['avail'] #price_in_data.text = ldays['price'] n in ldays: print (dfrom, roomid, n) #availability_in_data.text = get.ldays['avail'] #price_in_data.txt = get.ldays['price'] ldays[-1]['avail'] = str(ldays[-1]['avail']) ldays[-1]['price'] =str(ldays[-1]['price']) availability_in_data.text = ldays[-1]['avail'] price_in_data.text = ldays[-1]['price']
thank all!
Comments
Post a Comment