for 遍历
for item in redis_info:
print ("%s:" % item,redis_info[item])
运行结果:
('aof_enabled:', 0)
('db0:', {'keys': 9, 'expires': 0, 'avg_ttl': 0})
('multiplexing_api:', 'epoll')
('redis_version:', '3.2.9')
('sync_partial_ok:', 1)
('loading:', 0)
items 遍历
for (k1,v1) in redis_info.items():
print ('%s' % k1,v1)
运行结果:
('aof_enabled:', 0)
('db0:', {'keys': 9, 'expires': 0, 'avg_ttl': 0})
('multiplexing_api:', 'epoll')
('redis_version:', '3.2.9')
('sync_partial_ok:', 1)
('loading:', 0)
iteritems遍历:
for (k1,v1) in redis_info.iteritems():
print ('%s:' % k1,v1)
运行结果
('aof_enabled:', 0)
('db0:', {'keys': 9, 'expires': 0, 'avg_ttl': 0})
('multiplexing_api:', 'epoll')
('redis_version:', '3.2.9')
('sync_partial_ok:', 1)
('loading:', 0)