我目前正在用Python制作游戏.
我想要代码阅读:
[00:00:00] Name|Hello!
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
print(Fore.YELLOW + Style.BRIGHT + '['),
print strftime("%H:%M:%S"),
print ']',
print(Style.BRIGHT + Fore.RED + ' Name'),
print(Fore.BLACK + '|'),
print(Fore.WHITE + Style.DIM + 'Hello!')
time.sleep(5)
Run Code Online (Sandbox Code Playgroud)
相反 - 出于某种原因 - 它变成这样:
[ 00:00:00 ] Name | Hello!
Run Code Online (Sandbox Code Playgroud)
我不知道这段代码有什么问题,或者如何修复它.
我非常感谢能得到的所有帮助!谢谢.
抱歉可怕的头衔!我不知道该写什么,而不会让瓷砖长500字.
让我说我有
print 'Hi!'
print 'How are you?'
Run Code Online (Sandbox Code Playgroud)
有什么方法可以把它放到同一条线上吗?"你好你好吗?"
这是我目前使用的代码:
choice = raw_input('>: ')
if choice=='1':
menu1()
else:
print '' +choice
print 'is not a recognized commando.'
Run Code Online (Sandbox Code Playgroud)
我的其他代码是:
from colorama import Fore, Back, Style
print
print 'Now chatting with Tom'
time.sleep(2)
print
print
print(Fore.RED + 'Tom >: ') + print(Fore.GREEN + 'test')
Run Code Online (Sandbox Code Playgroud)
当然这没用.我只是想测试一下.
有什么方法可以把这两个字符串放到同一行吗?
非常感谢你!
编辑:
非常感谢大家!我知道Python最基本的部分,但我不知道如何忽略它,
无论如何.出于某种原因,我得到额外的空间.我想写[12:41:39](时间).在我的代码中,它看起来像这样:
print(Fore.YELLOW + '['),
print strftime("%H:%M:%S"),
print '] ',
Run Code Online (Sandbox Code Playgroud)
输出是[12:41:39]
我不知道这里有什么问题.我真的希望有人能为我解释一下!谢谢!
我正在制作MUD或SUD,因为我们可以称之为(单人游戏)导航游戏的唯一方法是键入命令.
def level_01_room_01():
choice = raw_input('>: ')
if choice == 'north':
level_01_room_02()
Run Code Online (Sandbox Code Playgroud)
在这种情况下,如果用户使用大写N输入North,则代码将不会感知此命令.如果我真的必须输入,那将是一个很大的混乱:
def level_01_room_01():
choice = raw_input('>: ')
if choice == 'North':
level_01_room_02()
if choice == 'north':
level_01_room_02()
if choice == 'NORTH':
level_01_room_02()
Run Code Online (Sandbox Code Playgroud)
等等.
有什么办法可以解决这个问题,这样玩家可以按照自己的意愿输入这个单词吗?