-->

SyntaxError错误打印(* ARGS,** kwargs)(SyntaxError prin

2019-10-29 03:35发布

我有一个错误,如下回溯:

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

错误发生时,我正在尝试运行这段代码:

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)

我已阅读并寻找类似的问题,但我仍然无法得到解决的错误。 谢谢

Answer 1:

尝试print(args, kwargs)代替print(*args, **kwargs)



文章来源: SyntaxError print(*args, **kwargs)