【问题标题】:SyntaxError print(*args, **kwargs)SyntaxError print(*args, **kwargs)
【发布时间】:2018-09-20 05:46:44
【问题描述】:

我在下面的回溯中有一个错误:

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)

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

【问题讨论】:

    标签: python python-2.x args keyword-argument rouge


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2017-04-07
      • 1970-01-01
      • 2013-08-04
      • 2020-09-16
      • 2017-01-28
      • 2017-03-26
      • 2021-07-26
      • 2022-09-22
      • 2012-12-06
      相关资源
      最近更新 更多