-Stores Key and value as a set.
To be honest, I'm not familiar with Perl's hash features.
Dictionaries in Python x = {"book":"Yomitai", "hon":3} Define key: value in {} like.
kiri.py
kiri = {"price":20, "number":12}
for key in kiri:
print(key+":"+str(kiri[key]))
for key, value in kiri.items(): You can get the dictionary key and value as a set by using the items method. At that time, str (value) may be used instead of str (kiri [key]).
In addition, format can be used for simplicity.
formatkiri.py
kiri = {"price":20, "number":12}
for key, value in kiri.items():
print("{0}:{1}".format(key, value))
(Maybe add)
Recommended Posts