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

python 输入参数解包,模块导入,接收IO输入参数

时间:2014-07-16 17:39:23      阅读:416      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   io   div   

#coding=utf-8

from sys import argv
script,first,second,third = argv

print "the script is=",script
print "the first is=",first
print "the second is=",second
print "the third is=",third

"""
执行方法
    D:\>python heidpython02.py aa bb cc
    the script is= heidpython02.py
    the first is= aa
    the second is= bb
    the third is= cc
"""

"""
参数少于三个
D:\>python heidpython02.py aa bb
Traceback (most recent call last):
  File "heidpython02.py", line 4, in <module>
    script,first,second,third = argv
ValueError: need more than 3 values to unpack
"""

"""
超出三个参数
D:\>python heidpython02.py aa bb 66 88
Traceback (most recent call last):
  File "heidpython02.py", line 4, in <module>
    script,first,second,third = argv
ValueError: too many values to unpack
"""


#####################
#接收用户输入
#####################
print "you name is ?"
name=raw_input()
print "how old are you?"
age=raw_input()

print "name:",name,"age:",age

 

python 输入参数解包,模块导入,接收IO输入参数,布布扣,bubuko.com

python 输入参数解包,模块导入,接收IO输入参数

标签:style   blog   color   os   io   div   

原文地址:http://www.cnblogs.com/heidsoft/p/3847793.html

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