语法错误打印(*args,**kwargs) [英] SyntaxError print(*args, **kwargs)

查看:77
本文介绍了语法错误打印(*args,**kwargs)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在下面的回溯中遇到错误:

I've got an error as a traceback below:

Traceback (most recent call last):
  File "setup_rouge.py", line 7, in <module>
    from files2rouge import settings
  File "/home/cerdas/files2rouge/files2rouge/__init__.py", line 2, in <module>
    from files2rouge.files2rouge import main
  File "/home/cerdas/files2rouge/files2rouge/files2rouge.py", line 17, in <module>
    from files2rouge import utils
  File "/home/cerdas/files2rouge/files2rouge/utils.py", line 14
    print(*args, **kwargs)
          ^
SyntaxError: invalid syntax

当我尝试运行此代码时发生错误:

The error occured when I'm trying to run this code:

def tee(saveto, *args, **kwargs):
    """Mimic the tee command, write on both stdout and file
    """
    print(*args, **kwargs)
    if saveto is not None:
        print(file=saveto, *args, **kwargs)

我已经阅读并搜索了类似的问题,但仍然无法解决错误.

I've read and searched for similar problems, but I still can't solve the error.

推荐答案

尝试 print(args, kwargs) 而不是 print(*args, **kwargs)

这篇关于语法错误打印(*args,**kwargs)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆