1

运行此命令时出现语法错误:

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"

它说“关闭”引号是语法错误-因为什么时候出现字符串语法错误?

4

1 回答 1

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")
于 2013-01-18T01:40:57.240 回答