我刚刚安装了PyCharm 3.4并获得了一些新的警告.不只是在这里,而是在很多地方.代码当然没问题.有人可以翻译PyCharm试图告诉我的内容以及如何沉默这些消息吗?
可能重复:
为什么python会这样排序我的字典?
为什么迭代这个词典
d = {'tors':None,
'head':None,
'armr':None,
'arml':None,
'legl':None,
'legr':None}
for k in d.keys():
print k
Run Code Online (Sandbox Code Playgroud)
将以不同的顺序输出键:
head
legl
armr
arml
tors
legr
Run Code Online (Sandbox Code Playgroud) 我有这个功能.我的pygame的文本到矩形转换器.
def text_to_rect(text, name='default'):
try:
font = load.text_style[name]['font']
aa = load.text_style[name]['aa']
color = load.text_style[name]['color']
except NameError:
font_path = pygame.font.get_default_font()
font = pygame.font.Font(font_path, 24)
aa = 1
color = (0,0,0)
if not name=='default':
text = text+'(ERROR: Global load object not defined.)'
except KeyError:
font_path = pygame.font.get_default_font()
font = pygame.font.Font(font_path, 24)
aa = 1
color = (0,0,0)
if not name=='default':
text = text+'(ERROR: '+name+' text style does not exist.)'
return font.render(text,aa,color)
Run Code Online (Sandbox Code Playgroud)
在两个除了块之外,有4行相同的代码.如果发生任何异常,我想运行这4行,然后休息到特定的异常.