random.random 语法无效
random.random invalid syntax
我在 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()
您在 print
附近缺少 ()
,该行应为:
print(random.random())
我在 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()
您在 print
附近缺少 ()
,该行应为:
print(random.random())