random.random无效语法

时间:2015-10-06 18:40:43

标签: python random syntax-error

我在Python上做了一个使用random.random()功能的简单游戏,但是我在脚本末尾的random.random()上得到了一个无效语法。 我不是很有才华,可能解决方案非常简单,但我只是不明白为什么它会给我发错误,我非常感谢你的帮助。

#Text based game
import time
import os
import sys
import random

start_time = time.clock()

def cls():
    os.system(['clear','cls'][os.name == 'nt'])

Class = "warrior"

print("Welcome to THE Game, the most epic text based Game you have ever played.")      #Please make a better name, thanks :)
start = input("Are you ready to start?: ")
cls()
if start == 'yes':
    name = input("What is your name?: ")
    cls()
    print("Welcome young traveler, here you will experience like nothing   you've experienced before (Ha, as if anything is new these days), but remember   ", name,", no one can protect you from this point on.")
    input("Press any key to continue: ")
    cls()
    print("Please choose a character.")
    print("")

else:
    print random.random()
    input()
    quit()

1 个答案:

答案 0 :(得分:1)

()周围缺少print,该行应为:

print(random.random())