擅长:python、mysql、java
<p>考虑到你的后续评论,听起来你在试图做如下事情:</p>
<pre><code>arr1 = { 'sensor1' : ' ', 'sensor2' : ' ', 'sensor_n' : ' ' } #dictionary of sensors (a blank associative array)
#take not of the curly braces '{ }'
#inside the braces are key : value pairs
arr1['sensor1'] = 23
arr1['sensor2'] = 55
arr1['sensor_n'] = 125
print arr1
for k,v in arr1.iteritems():
print k,v
for i in arr1:
print arr1[i]
</code></pre>
<p><a href="http://docs.python.org/2/tutorial/datastructures.html#dictionaries" rel="nofollow">Python Tutorials on Dictionaries</a>应该能够给你所寻求的洞察力。</p>