SyntaxError print(*args, **kwargs)

安稳与你 提交于 2019-12-25 01:00:14

问题


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 searching for similar problem, but i still can't solved the error. Thanks


回答1:


Try print(args, kwargs) instead of print(*args, **kwargs)



来源:https://stackoverflow.com/questions/52418360/syntaxerror-printargs-kwargs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!