random.random无效语法

编程入门 行业动态 更新时间:2024-10-24 14:19:49
本文介绍了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无效语法

本文发布于:2023-11-30 00:38:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1648146.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:语法   random

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!