实验第一个python程序
时间:2008-03-10 来源:travelsky2008
1.查看python的版本信息
[wangli@rd-openet-ww wangli]$ python -V //V要大写
Python 2.5.2
#!usr/bin/python
#filename:hellowrold.py
contact = {}
contact_list = []
while 1:
contact['name'] = raw_input("please input name: ")
contact['phone'] = raw_input("please input phone number: ")
contact_list.append(contact.copy())
go_on = raw_input("continue?\n")
if go_on == "yes":
pass
elif go_on == "no":
break
else:
print "you didn't say no\n"
i = 1
for contact in contact_list:
print "%d: name=%s" % (i, contact['name'])
print "%d: phone=%s" % (i, contact['phone'])
i = i + 1
3.也可在解析器下运行
>>> import sys
>>> sys.stdout.write("Hello World!\n")
Hello World!
>>>
退出解释器的方法是Ctrl+D或者Ctrl+Z
相关阅读 更多 +