golanghttp://goclipse.github.io/releases/
python http://pydev.org/updates
golanghttp://goclipse.github.io/releases/
python http://pydev.org/updates
import datetime
nowDate = datetime.datetime.now()
weekFriday = ''.join(str(nowDate+datetime.timedelta(days=4-date1.weekday())).split()[0].split('-'))
print(weekFriday)
如上获取本周星系五的日期
判断是否有操作权限
def with_permission(permission):
''''''
def _decorator(method):
''''''
@functools.wraps(method)
def wrapper(self, *args, **kwargs):
''''''
user = self.current_user # 这里判断用户是否存在(登录)
if not user:
self.set_status(404)
return
if permission in user.permission_list: # 判断用户是否有足够的权限
method(self, *args, **kwargs)
else:
data = {"error": "need permission:%s" % permission}
self.write_json(data, status=403)
return wrapper
return _decorator
转载地址:https://www.bbsmax.com/A/x9J2DbAWd6/
Google Authenticator基本上实现了两种类型的密码:
HOTP – 基于HMAC的一次性密码,这意味着密码随着每次呼叫而改变,符合RFC4226
TOTP – 基于时间的一次性密码,每30秒钟更换一次。
Google身份验证器也可以在此处以开放源代码形式提供:code.google.com/p/google-authenticator
python3
# -*- coding:utf-8 -*- import hmac, base64, struct, hashlib, time def get_hotp_token(secret, intervals_no): key = base64.b32decode(secret, True) msg = struct.pack(">Q", intervals_no) h = hmac.new(key, msg, hashlib.sha1).digest() o = ord(chr(h[19])) & 15 h = (struct.unpack(">I", h[o:o+4])[0] & 0x7fffffff) % 1000000 return h def get_totp_token(secret): return get_hotp_token(secret, intervals_no=int(time.time())//30) print(get_totp_token('xxxxxxxxx'))
本来是想找个函数,但是网上大部分都是for和while太麻烦,如下即可。
从0加到5
sum([n for n in range(6)])