zoukankan      html  css  js  c++  java
  • python 输入参数解包,模块导入,接收IO输入参数

    #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
  • 相关阅读:
    iOS进阶二-KVC
    iOS进阶一OC对象的本质
    2019-01-19
    2019-01-12
    2019
    2018-12-23 随笔
    2018-12-18 随笔
    2018-12-10
    2018-12-01
    2018.11.23 随笔
  • 原文地址:https://www.cnblogs.com/heidsoft/p/3847793.html
Copyright © 2011-2022 走看看