I have a problem with changing the dict value and saving the dict in a text file (the format should be the same), I only want to change the member_phone field.
My text file has the following format:
memberID:member_name:member_email:member_phone
and I split the text file into:
mdict={} for line in file: x=line.split(':') a=x[0] b=x[1] c=x[2] d=x[3] e=b+':'+c+':'+d mdict[a]=e
When I try to change the member_phone stored in d , the value is not changed to a stream,
def change(mdict,b,c,d,e): a=input('ID') if a in mdict: d= str(input('phone')) mdict[a]=b+':'+c+':'+d else: print('not')
and how to save the dict in a text file in the same format?
XueYuan Wang 05 Oct '13 at 18:34 2013-10-05 18:34
source share