2015-11-24 58 views
-3

在'DisplayBands'函数后面的':'上我得到一个无效的语法错误,但是我没有看到语法错误。我可能是盲人。帮助是非常赞赏(请原谅我的愚蠢,我很新的这一点。)语法错误,但语法有效?

import time 
import random 

def DisplayBands: 
    print("Guess the name of the band out of:") 
    print("One Dimension") 
    print("Take What?") 
    print("Austin Eabier") 
    print("Front Street Lads") 
    now = time.time() 
    return now 
+2

请重读如何在Python定义函数... – nneonneo

+1

你需要'()'所以,不,它不是有效的语法 –

回答

0

你必须把()后函数声明:

def DisplayBands(): 
    print("Guess the name of the band out of:") 
    print("One Dimension") 
    print("Take What?") 
    print("Austin Eabier") 
    print("Front Street Lads") 
    now = time.time() 
    return now 
+0

谢谢这么多,我是一个白痴:) – ClassyMelon

3

函数定义需要在括号函数名称的结尾。

def DisplayBands(): 
       ^^ These are required 

在这种情况下,要定义一个函数,0参数