[python-win32] How to replace the values with keys ?
Tim Roberts
timr at probo.com
Tue Jul 22 18:39:18 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?
reverseText2 = dict( (b,a) for a,b in Text2.items() )
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the python-win32
mailing list