[python-win32] How to replace the values with keys ?

Larry Bates larry.bates at websafe.com
Tue Jul 22 15:12:57 CEST 2008


Graps Graps wrote:
> Hi all,
> 
> I am a newbie to python... I have two text files text1 and text2. Text1 
> is a tabbed separated file, say like
> 
> a b
> a c
> a d
> a g
> b c
> b d
> b h
> c d
> c h... and so on..
> 
> Text2 is a python dictionary containing data as
> 
> {0: 'a', 1: 'b', 2: 'c'...}
> 
> now I want the data in text1 to be replaced with the keys, say like
> 
> 0 1
> 0 2
> 0 3
> 0 6
> 1 2... so on..
> Is there some way I could do it in python?
> 
> Thanking in advance..,
> GraPs
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32

This list is for questions about Python's Win32 extensions and Python's 
interfaces to Windows.  I don't see anything in your post that relates to either 
of these issues.  You should try comp.lang.python instead.

The short answer to your question is "yes".  But since you didn't show us that 
you have actually tried anything AND this looks a lot like a homework problem, I 
will leave you to actually post something that you have done before answering 
further.

-Larry



More information about the python-win32 mailing list