s={
'userName': "4-12\u4e2a\u82f1\u6587\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf",
'userNameMin': "\u4e0d\u80fd\u5c0f\u4e8e4\u4e2a\u5b57",
'userNameMax': "\u4e0d\u80fd\u8d85\u8fc712\u4e2a\u5b57",
'userNameExist': "\u8be5\u7528\u6237\u540d\u5df2\u88ab\u6ce8\u518c\u4e86\uff0c\u8bf7\u6362\u6362",
'userNameInvalid': "\u53ea\u652f\u6301\u82f1\u6587\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf",
'userNameStartInvalid': "\u7528\u6237\u540d\u4e0d\u80fd\u4ee5\u4e0b\u5212\u7ebf\u5f00\u5934",
'nickName': "6\u4f4d\u4ee5\u5185\u4e2d\u6587\u621612\u4f4d\u4ee5\u5185\u82f1\u6587\u5b57\u7b26",
'nickNameMin': "\u4e0d\u80fd\u5c0f\u4e8e1\u4e2a\u5b57",
'nickNameMax': "\u4e0d\u80fd\u8d85\u8fc76\u4e2a\u6c49\u5b57\u621612\u4e2a\u82f1\u6587\u5b57\u7b26",
'nickNameExist': "\u8be5\u540d\u5b57\u5df2\u88ab\u5360\u7528\uff0c\u8bf7\u6362\u6362",
'nickNameInvalid': "\u53ea\u652f\u6301\u4e2d\u6587\u3001\u5b57\u6bcd\u6216\u6570\u5b57\uff0c\u4e0d\u652f\u6301\u7a7a\u683c\u548c\u7279\u6b8a\u7b26\u53f7",
'nickNameError': "\u540d\u5b57\u4e2d\u542b\u6709\u8fdd\u7981\u8bcd\uff0c\u8bf7\u4fee\u6539\uff0c\u671b\u8c05\u89e3",
'password': "6-16\u4f4d\u82f1\u6587\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf",
'passwordMin': "\u4e0d\u80fd\u5c0f\u4e8e6\u4e2a\u5b57\u7b26",
'passwordMax': "\u4e0d\u80fd\u8d85\u8fc716\u4e2a\u5b57\u7b26",
'passwordInvalid': "\u53ea\u652f\u6301\u82f1\u6587\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf",
'password1': "\u8bf7\u518d\u786e\u8ba4\u4e00\u6b21\u4f60\u8f93\u5165\u7684\u5bc6\u7801",
'password1Invalid': "\u4e24\u6b21\u5bc6\u7801\u8f93\u5165\u4e0d\u4e00\u81f4",
'email': "\u8bf7\u8f93\u5165\u4f60\u5e38\u7528\u7684Email",
'emailExist': "\u8be5Email\u5df2\u88ab\u6ce8\u518c",
'emailInvalid': "Email\u683c\u5f0f\u4e0d\u6b63\u786e",
'sex': "\u8bf7\u9009\u62e9\u4f60\u7684\u6027\u522b",
'validateCode': "\u8bf7\u8f93\u5165\u56fe\u50cf\u4e2d\u7684\u6587\u5b57",
'validateCodeInvalid': "\u9a8c\u8bc1\u7801\u9519\u8bef",
'loading': '<img align="absmiddle" alt="" src="http://images.digu.com/web_res_v1/images/ico_loading16.gif" /> \u6b63\u5728\u68c0\u67e5\u552f\u4e00\u6027',
'checkCode': '<img align="absmiddle" alt="" src="http://images.digu.com/web_res_v1/images/ico_loading16.gif" /> \u6b63\u5728\u68c0\u67e5\u9a8c\u8bc1\u7801',
'ok': '<img align="absmiddle" alt="ok" src="http://images.digu.com/web_res_v1/images/ico_valid.gif" />',
'required': "\u5fc5\u586b"
}
for i,j in s.items():
print i,j.decode('unicode-escape')
output:
输出:
password1 请再确认一次你输入的密码
required 必填
userNameExist 该用户名已被注册了,请换换
nickNameMax 不能超过6个汉字或12个英文字符
checkCode <img align="absmiddle" alt="" src="http://images.digu.com/web_res_v1/images/ico_loading16.gif" /> 正在检查验证码
userNameMin 不能小于4个字
userNameMax 不能超过12个字
userNameInvalid 只支持英文字母、数字和下划线
sex 请选择你的性别
nickNameExist 该名字已被占用,请换换
emailExist 该Email已被注册
passwordMax 不能超过16个字符
emailInvalid Email格式不正确
loading <img align="absmiddle" alt="" src="http://images.digu.com/web_res_v1/images/ico_loading16.gif" /> 正在检查唯一性
userNameStartInvalid 用户名不能以下划线开头
passwordInvalid 只支持英文字母、数字和下划线
validateCode 请输入图像中的文字
passwordMin 不能小于6个字符
nickName 6位以内中文或12位以内英文字符
email 请输入你常用的Email
nickNameError 名字中含有违禁词,请修改,望谅解
password 6-16位英文字母、数字和下划线
userName 4-12个英文字母、数字和下划线
ok <img align="absmiddle" alt="ok" src="http://images.digu.com/web_res_v1/images/ico_valid.gif" />
nickNameMin 不能小于1个字
password1Invalid 两次密码输入不一致
nickNameInvalid 只支持中文、字母或数字,不支持空格和特殊符号
validateCodeInvalid 验证码错误
My question is: the order is disturbed
我的问题是:订单被打乱了。
how does Output sequence.
如何输出序列。
thanks
谢谢
4 个解决方案
#1
5
Use OrderedDict on python 2.7+
使用OrderedDict在python 2.7+上。
Or change dict to tuple or list, something like this
或者把字典改成tuple或list,像这样。
[
('userName', "4-12\u4e2a\u82f1\u6587\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf"),
('userNameMin', "\u4e0d\u80fd\u5c0f\u4e8e4\u4e2a\u5b57"),
....
]
And use s
instead of s.items()
用s代替。items()
for i,j in s:
print i,j.decode('unicode-escape')
#2
2
dicts are unsorted. If you need keys to be output in a specific order then use a list to hold them, then index the dict by each of the keys in order.
字典是无序的。如果您需要以特定顺序输出的键,那么使用一个列表来保存它们,然后按顺序索引每个键的命令。
#3
1
you could always do a sort before you print ?
你可以在打印前做排序?
for k in sorted(s.keys()):
print k,s[k].decode('unicode-escape')
#4
0
Use tuple ()
or array []
instead of dictionary/map {}
- tuples and arrays keep their sequence but do not allow using keys, dictionaries do not keep their sequence but allow using keys.
使用tuple()或数组[]而不是字典/map{} -元组和数组保存它们的序列,但是不允许使用键,字典不保留它们的顺序,而是允许使用键。
s=(
('userName', "4-12\u4e2a\u82f1\u6587\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf"),
('userNameMin', "\u4e0d\u80fd\u5c0f\u4e8e4\u4e2a\u5b57"),
('userNameMax', "\u4e0d\u80fd\u8d85\u8fc712\u4e2a\u5b57"),
.
.
.
)
for (i,j) in s:
print i,j.decode('unicode-escape')
#1
5
Use OrderedDict on python 2.7+
使用OrderedDict在python 2.7+上。
Or change dict to tuple or list, something like this
或者把字典改成tuple或list,像这样。
[
('userName', "4-12\u4e2a\u82f1\u6587\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf"),
('userNameMin', "\u4e0d\u80fd\u5c0f\u4e8e4\u4e2a\u5b57"),
....
]
And use s
instead of s.items()
用s代替。items()
for i,j in s:
print i,j.decode('unicode-escape')
#2
2
dicts are unsorted. If you need keys to be output in a specific order then use a list to hold them, then index the dict by each of the keys in order.
字典是无序的。如果您需要以特定顺序输出的键,那么使用一个列表来保存它们,然后按顺序索引每个键的命令。
#3
1
you could always do a sort before you print ?
你可以在打印前做排序?
for k in sorted(s.keys()):
print k,s[k].decode('unicode-escape')
#4
0
Use tuple ()
or array []
instead of dictionary/map {}
- tuples and arrays keep their sequence but do not allow using keys, dictionaries do not keep their sequence but allow using keys.
使用tuple()或数组[]而不是字典/map{} -元组和数组保存它们的序列,但是不允许使用键,字典不保留它们的顺序,而是允许使用键。
s=(
('userName', "4-12\u4e2a\u82f1\u6587\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf"),
('userNameMin', "\u4e0d\u80fd\u5c0f\u4e8e4\u4e2a\u5b57"),
('userNameMax', "\u4e0d\u80fd\u8d85\u8fc712\u4e2a\u5b57"),
.
.
.
)
for (i,j) in s:
print i,j.decode('unicode-escape')