Python डिक्शनरीज़

MATLAB उपयोगकर्ताओं के लिए Python

Justin Kiggins

Product Manager

डिक्शनरी क्या है?

  • MATLAB structure array जैसा
  • key:value पेयर्स का कलेक्शन
  • ऑर्डर की गारंटी नहीं होती
MATLAB उपयोगकर्ताओं के लिए Python

डिक्शनरी से डेटा निकालना

type(definitions)
dict
print(definitions['aardvark'])
A nocturnal burrowing mammal with long ears, a tubular snout, and a long 
extensible tongue, feeding on ants and termites. Aardvarks are native to 
Africa and have no close relatives.
MATLAB उपयोगकर्ताओं के लिए Python

डिक्शनरी बनाना

# Create a dictionary
dog = {'name': 'Toby', 'breed': 'Basset Hound'}
MATLAB उपयोगकर्ताओं के लिए Python

डिक्शनरी में डेटा जोड़ना

# Add more key:value pairs
dog['weight (lbs)'] = 552.3
dog['birthdate'] = "2016-06-26"
print(dog)
{'name': 'Toby',
 'breed': 'Basset Hound',
 'weight (lbs)': 552.3, 
 'birthdate': '2016-06-26'}
MATLAB उपयोगकर्ताओं के लिए Python

डिक्शनरी अपडेट करना

# Update weight value
dog['weight (lbs)'] = 52.3

print(dog)
{'name': 'Toby',
 'breed': 'Basset Hound',
 'weight (lbs)': 52.3,
 'birthdate': '2016-06-26'}
MATLAB उपयोगकर्ताओं के लिए Python

डिक्शनरी से डेटा हटाना

dog.pop('birthdate')
print(dog)
{'name': 'Toby',
 'breed': 'Basset Hound',
 'weight (lbs)': 52.3}
MATLAB उपयोगकर्ताओं के लिए Python

अभ्यास करते हैं!

MATLAB उपयोगकर्ताओं के लिए Python

Preparing Video For Download...