how can i rename key value in python?
i have this code :
t = { u'last_name': [u'hbkjh'], u'no_of_nights': [u'1'], u'check_in': [u'2012-03-19'], u'no_of_adult': [u'', u'1'], u'csrfmiddlewaretoken': [u'05e5bdb542c3be7515b87e8160c347a0'], u'memo': [u'kjhbn'], u'totalcost': [u'1800.0'], u'product': [u'4'], u'exp_month': [u'1'], u'quantity': [u'2'], u'price': [u'900.0'], u'first_name': [u'sdhjb'], u'no_of_kid': [u'', u'0'], u'exp_year': [u'2012'], u'check_out': [u'2012-03-20'], u'email': [u'ebmalifer@agile.com.ph'], u'contact': [u'3546576'], u'extra_test1': [u'jknj'], u'extra_test2': [u'jnjl'], u'security_code': [u'3245'], u'extra_charged': [u'200.0']}
key = {str(k): str(v[0]) for k,v in t.iteritems() if k.startswith('extra_')}
array = []
for val in key:
data = str(val) + ' = ' + key[val] + ','
array.append(data)
print array
it give me this :
["extra_charged = 200.0,", "extra_test1 = jknj,", "extra_test2 = jnjl,"]
what should i do to remove the 'extra_' and it makes the output like this:
["CHARGED = 200.0,", "TEST1 = jknj,", "TEST2 = jnjl,"]
can anyone have an idea about my case?
thanks in advance …
i found this
.replace()and i do like this ..