加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python – 缺少预期的输出

发布时间:2020-12-20 12:26:45 所属栏目:Python 来源:网络整理
导读:我试图使用“ python ex18.py”命令从电子书学习 Python硬盘中运行此文件,但它不输出任何内容.怎么了? # this one is like your scripts with argvdef print_two(*args): arg1,arg2 = args print "arg1: %r,arg2: %r" % (arg1,arg2)# ok,that *args is actu
我试图使用“ python ex18.py”命令从电子书学习 Python硬盘中运行此文件,但它不输出任何内容.怎么了?

# this one is like your scripts with argv
def print_two(*args):
    arg1,arg2 = args
    print "arg1: %r,arg2: %r" % (arg1,arg2)

# ok,that *args is actually pointless,we can just do this
def print_two_again(arg1,arg2):
    print "arg1: %r,arg2)

# this takes just one argument
def print_one(arg1):
    print "arg1: %r" % arg1

# this one takes no arguments
def print_none():
    print "I got nothin'."

解决方法

因为该文件实际上并不调用任何函数,所以无需输出任何内容.

该文件只定义了四个函数,然后对它们不执行任何操作.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读