---
title: "python的map遍历代码"
author: "agile_boy"
date: "2007-01-28T17:49:03Z"
tags: ["C", "C++", "OS", "Python", "Windows"]
slug: "python-map"
draft: false
lastmod: "2007-01-28T17:49:03Z"
id: 50907
url: "https://agile-boy.iteye.com/blog/50907"
---

好久没有用python了，感觉基本的语法都生疏了，比如map的遍历：）

python 代码

 

1. 例 6.10. 遍历 dictionary
2. &gt;&gt;&gt; import os
3. &gt;&gt;&gt; for k, v in os.environ.items():      1 2
4. ...     print "%s=%s" % (k, v)
5. USERPROFILE=C:\\Documents and Settings\\mpilgrim
6. OS=Windows\_NT
7. COMPUTERNAME=MPILGRIM
8. USERNAME=mpilgrim

详细参考 [www.woodpecker.org.cn/diveintopython/file\_handling/for\_loops.html](http://www.woodpecker.org.cn/diveintopython/file_handling/for_loops.html)