字典键盘通话
问题描述:
即时通讯构建一个测试程序。它基本上是一个错误和错误修复的数据库。它可能最终成为我在Python中工作的整个数据库。 我想通过使用字典创建图层的效果。字典键盘通话
这里是代码,2011年4月29日的:
modules=['pass']
syntax={'PRINT':''' in eclipse anthing which
you "PRINT" needs to be within a set of paranthesis''','StrRet':'anytime you need to use the return action in a string, you must use the triple quotes.'}
findinp= input('''where would you like to go?
Dir:''')
if findinp=='syntax':
print(syntax)
dir2= input('choose a listing')
if dir2=='print'or'PRINT'or'Print':
print('PRINT' in syntax)
现在,当我使用这个我得到了整个字典,而不是仅仅是第一层。我将如何做这样的事情?我是否需要在控制台中列出链接?还是有更好的方法来做到这一点?
谢谢, Pre.Shu。
答
我不太清楚你想要什么,但打印字典您指数的一个关键内容是:
syntax['PRINT']
也许这有点帮助:
modules=['pass']
syntax={
'PRINT':''' in eclipse anthing which
you "PRINT" needs to be within a set of paranthesis''',
'STRRET':'anytime you need to use the return action in a string, you must use the triple quotes.'}
choice = input('''where would you like to go?
Dir:''').upper()
if choice in syntax:
print syntax[choice]
else:
print "no data ..."
+0
在oupt我得到: 你想去哪里? Dir:语法 {'PRINT':'在eclipse中,其中\ nyou“PRINT”需要位于一组paranthesis中,'StrRet':'任何时候您需要在字符串中使用返回动作,y ou '} 选择一个列表 我想要得到: 你想去哪里? 导演:语法 语法包含:PRINT和StrRet 导演:“在日食参选其中\ n您‘打印’必须是一组paranthesis内” 别的打印 ? 是或否:是 *程序关闭* – 2011-04-30 16:04:41
格式的源代码正确! – 2011-04-30 15:33:10