给出语法错误python的Print命令

2024-06-17 07:46:43 发布

您现在位置:Python中文网/ 问答频道 /正文

这是我的一个简单函数的代码,因为我是初学者

def repeat(s, exclaim):
    result = s*3
    if exclaim:
        result = result + '!!!'
    return result
def main():
    print repeat('Yay', False)
    print repeat('Woo Hoo', True)

if __name__ == '__main__':
    main()

但是当我运行这段代码时,它显示了一个错误 print repeat('Yay', False) 语法错误:无效语法 请帮忙


Tags: 函数代码falsereturnifmaindefresult