字符串中的语法错误

时间:2013-01-18 01:38:05

标签: python

运行时遇到语法错误:

class Stats:
    Str = random.randint(3,18)
    Int = random.randint(3,18)
    Wis = random.randint(3,18)
    Char = random.randint(3,18)
    Con = random.randint(3,18)
    print "Type the name of a stat (Str, Int, Wis, Char or Con) to see its value"

它说'结束'引用是语法错误 - 因为字符串语法错误何时?

1 个答案:

答案 0 :(得分:3)

您使用的是python 3+吗? print是python 3中的一个函数。

class Stats:
    Str = random.randint(3,18)
    Int = random.randint(3,18)
    Wis = random.randint(3,18)
    Char = random.randint(3,18)
    Con = random.randint(3,18)
    print("Type the name of a stat (Str, Int, Wis, Char or Con) to see its value")