1 Replies - 161 Views - Last Post: 27 October 2013 - 10:25 AM Rate Topic: -----

#1 vasant_Gowda  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 27-August 13

storing in dictionary format

Posted 15 October 2013 - 08:40 PM

Hi friends,

I have a file which is of the form

/TITLE 'Alfa Fx Hot end' : 'Casted bracket"

My question is I have to store /TITLE in one variable and rest of the line in another variable
Is This A Good Question/Topic? 0
  • +

Replies To: storing in dictionary format

#2 witeboy724  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 29
  • Joined: 21-June 12

Re: storing in dictionary format

Posted 27 October 2013 - 10:25 AM

I'm not sure you really want dictionary format, but here's how I'd do it using split:

d = {}  # Make dictionary

lineraw = "/TITLE 'Alfa Fx Hot end' : 'Casted bracket"

part1 = lineraw.split(' ',1)[0]  # Split
part2 =  lineraw.split(' ',1)[1]

print part1  # Print if you want
print part2

d[part1] = part2  # In dictionary.  


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1