0

 s = {"densityThreshold": 2.4543288981124E+14}

I was thinking something like this

 re.search(".[A-Za-z]*.:\s\d\.\d+..\d+", k) or if re.search(".[A-Za-z]*.:\s\d\.\w+.\d+", k):

but neither seem to work..

I need to group "densityThreshold" and "2.4543288981124E+14" to create another dictionary.. I would usually use group() but i m stuck at search!

Dolda2000
  • 25,216
  • 4
  • 51
  • 92
user2921139
  • 1,669
  • 4
  • 17
  • 25

1 Answers1

0
x='s = {"densityThreshold": 2.4543288981124E+14}'
k=re.search(".[A-Za-z]*.:\s\d\.\d+..\d+", x)
print k.group()

You can do this if you want the whole thing in one group.Or if you want separately use

x='s = {"densityThreshold": 2.4543288981124E+14
k=re.search("(.[A-Za-z]*.):(\s\d\.\d+..\d+)", x)
print k.groups()
vks
  • 67,027
  • 10
  • 91
  • 124