码迷,mamicode.com
首页 > 编程语言 > 详细

python字典练习

时间:2016-09-04 14:29:13      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:

[root@localhost test1]# vim 4.py
//ADD
#!/usr/bin/python

info = {}
name = raw_input("Please input a name: ")
age = raw_input("Please input your age: ")
gender = raw_input("Please input (M/F): ")
info[name] = name
info[age] = age
info[gender] = gender
for k, v in info.items():
    print "%s: %s" % (k, v)
print main end

[root@localhost test1]# python 4.py
Please input a name: Mike
Please input your age: 30
Please input (M/F): M
gender: M
age: 30
name: Mike
main end

 

python字典练习

标签:

原文地址:http://www.cnblogs.com/frankielf0921/p/5839207.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!