Mod重写Ft子目录和目录的Htaccess(Mod Rewrite Htaccess for Fake sub Directories and directory)
我正在尝试创建虚假目录以将特定参数重定向到特定子目录:来自:www.example.com/sys/signup要访问:www.example.com/system/ext.php?t = signup
I am trying to create fake directories to redirect specific parameters to specific subdirectories as such: From: www.example.com/sys/signup To: www.example.com/system/ext.php?t=signup
原文:https://stackoverflow.com/questions/27258104
最满意答案
为了回答我自己的问题,Engine.main()中的循环就像它应该的那样工作,但是我从while语句中取出了self.room.describe():
def main(self): self.room.describe() #Describes the current room. while True: # Ask for user prompt input = raw_input(self.room.prompt) cmd = input.lower() ...etc, etc, etc...
然后我将GoCommand更改为:
class GoCommand(Command): def __init__(self, direction): self.direction = direction def execute(self): # 'E' is the instantiation of the Engine class, declared within engine.py from engine import E # self.direction is 'north' in our example if self.direction in E.room.map.keys(): print "You head %s\n" % self.direction # Pretty explanatory E.room = E.room.map[self.direction] print E.room.describe() else: print "You can't go that way."
一切都按照应有的方式运作。
To answer my own question, the loop in Engine.main() works just as its supposed to, but I took self.room.describe() out of the while statement:
def main(self): self.room.describe() #Describes the current room. while True: # Ask for user prompt input = raw_input(self.room.prompt) cmd = input.lower() ...etc, etc, etc...
Then I changed the GoCommand to:
class GoCommand(Command): def __init__(self, direction): self.direction = direction def execute(self): # 'E' is the instantiation of the Engine class, declared within engine.py from engine import E # self.direction is 'north' in our example if self.direction in E.room.map.keys(): print "You head %s\n" % self.direction # Pretty explanatory E.room = E.room.map[self.direction] print E.room.describe() else: print "You can't go that way."
And everything works as its supposed to.
相关问答
更多-
Python代码文本游戏(Python Code Text Game)[2022-03-11]
您不能将字符串与整数连接,而是可以使用format print('The enemy\'s health is at {}! Keep attacking Guardian!'.format(enemy_health)) 要使用+运算符并执行连接,首先必须先创建一个字符串 print('The enemy\'s health is at ' + str(enemy_health) + '! Keep attacking Guardian!' 你还需要实际修改他们的健康状况,我不确定你认为这是做什么的 e ... -
python 3.x - 基于文本的冒险游戏,保存游戏功能(python 3.x - text based adventure game, save game function)[2023-08-04]
你似乎有一些定义状态的东西:self .__ player_health,self .__ player_name,self .__ health_potion,self .__ big_wrench,self .__ blue_keycard。 我需要仔细阅读,但找不到定义进展的状态。 使用定义状态的所有内容,您可以保存并从文本文件中读取 - 如果您的目标是简单性。 一种方法是使用dict结构来存储文本,等待时间和功能(如果可用,如战斗),如页面。 然后使用数组来存储这些页面,这将是你的书。 如果你有一个 ... -
Python文本游戏的麻烦(Trouble with Python Text Game)[2023-06-02]
为了回答我自己的问题,Engine.main()中的循环就像它应该的那样工作,但是我从while语句中取出了self.room.describe(): def main(self): self.room.describe() #Describes the current room. while True: # Ask for user prompt input = raw_input(self.room.prompt) cmd = input. ... -
我认为发生“失败”是因为每次char_loc不在51和55之间时都会发生。 if (char_loc >= 11 and char_loc <= 15): if (char_loc >= 21 and char_loc <= 25): if (char_loc >= 31 and char_loc <= 35): if (char_loc >= 41 and char_loc <= 45): if (char_loc >= 51 and char_loc <= 55): else: 我认为你想在这里做的是 ...
-
首先,如果你正在使用python2.7,你需要知道input(),如果你通过控制台给它一个数字,这个函数转换为int,那么你需要检查值,如果choice == 1或只是将输入更改为raw_input() (这是最好的方法), if choice!='1' and choice!='2':需要放入else:那么可以避免大量检查或意外值。 如果你使用python3,raw_input是新的输入函数,所以你不需要改变它 最后,如果你想使用raw_input()或者你正在使用python3,你需要将随机函数改为ra ...
-
Pickle本身有其他的协议,比默认协议(协议0)更紧凑 - 这是唯一的“基于文本” - 其他协议是二进制协议。 但是,他们几乎不会超过文件大小的50% - 能够增强答案,我们需要更好地了解您正在保存的内容,以及是否有更聪明的方式来保存数据 - 例如,通过避免如果它存在于您的几个房间中,则重复相同的子数据结构。 (尽管如果你在游戏中使用对象身份,Pickle应该照顾到这一点)。 也就是说,只需将pickle.dump调用更改为包含协议参数 - -1值相当于“HIGHEST_PROTOCOL”,通常这是最高效 ...
-
这是一个相当开放的问题(不必下载任何“插件”)? 但你想要的是curses库,Python与curses模块有一个接口。 Python文档提供了一个使用它的简单教程 。 还有一个名为Blessings的库,它为curses提供了一个更好,更现代的面向对象的接口。 我没有尝试过,但它得到了很好的支持,看起来还不错。 This is a rather open-ended question (not have to download any "plugins")? But what you want is th ...
-
我没有看到相关的代码实际上在屏幕上显示蛇的当前位置,并在移动后将其移除,但如果您将蛇的长度变为变量并将其绘制并移除,则可以在这里更改大小一种迭代的方式。 当食物被吃掉时,你可以简单地增加蛇长度变量的大小,并且随着蛇的移动沿着其向量进行,直到期望的增长发生时暂停清除蛇的移动,此时可以以新的长度进行移动。 请澄清实际呈现蛇位置的代码部分。 I do not see the associated code that actually displays the current position of the sna ...
-
Python游戏没有响应(Python game not responding)[2023-03-22]
你有两个while True循环 - 一个接一个。 第一 done = False while not done: for event in pygame.event.get(): if event.type == pygame.QUIT: done = True elif event.type == pygame.MOUSEBUTTONDOWN: click_sound.play() 正在运行,直到你点击“X”按钮 ... -
这是你追求的结构吗? choices = { 1 : { 'prompt' : { 'prompt' : 'Level 1 prompt', 'A' : 'Choice A', 'B' : 'Choice B', 'C' : 'Choice C' }, }, 2 : { 'promptA' : { 'prompt' : 'Level 2 prompt A', ...