python parse string and turn into dictionary input -


यह मेरी सूची है:

  list1 = ('/ a / b / c / List1: y = x में x के लिए hel1 / d / e ',' / a / b / c / hel2 / d / e ',' / a / b / c / हैलो 3 / डी / ई ') list2 = [] विभाजित ('/') [4] list2.append (y) list2 = ['हैलो 1', 'हैलो 2', 'हैलो 3']  

अब मैं एक शब्दकोश बनाना चाहता हूँ जहां हैलो [1-3] मेरी चाबी है और संबंधित स्ट्रिंग '/ a / b / c / नमस्ते [1-3] / डी / ई' मान है। मैं पायथन में कुंजी और मान कैसे कनेक्ट कर सकता हूं मुझे यकीन है कि यह काफी आसान है, लेकिन मुझे नहीं पता।

धन्यवाद।

आप इसे प्राप्त करने के लिए एक डिक्की समझ का उपयोग कर सकते हैं।

  & gt ; & gt; & gt; {S.split ('/') [4]: ​​s के लिए सूची 1} {'हैलो 2': '/ ए / बी / सी / हैलो 2 / डी / ई', 'हैलो 3': '/ ए / बी / सी / हैलो 3 / डी / ई ',' हैलो 1 ':' / ए / बी / सी / हैलो 1 / डी / ई '}   

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -