打印 random.random 无效语法[重复]

问题描述 投票:0回答:1

我正在 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()
python random syntax-error
1个回答
2
投票

您在

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

print(random.random())
© www.soinside.com 2019 - 2024. All rights reserved.