random.random无效语法 [英] random.random invalid syntax

查看:328
本文介绍了random.random无效语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm doing a simple game on Python that uses a random.random() feature, however I'm getting a Invalid Syntax on random.random() in the end of the script. I am not very talented and probably the solution is very simple, but I just don't get why is it sending me the error, I would very much appreciate your help.

#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()

推荐答案

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

You are missing () around print, the line should read:

print(random.random())

这篇关于random.random无效语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆