This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# turntable.py 幸运转盘抽奖 | |
import random | |
import bisect | |
class WeightRandom: | |
def __init__(self, items): | |
weights = [w for _, w in items] | |
self.goods = [x for x, _ in items] | |
self.total = sum(weights) | |
self.acc = list(self.accumulate(weights)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<from> | |
<div class="form-group"> | |
<label >工会ID</label> | |
<input class="form-control" id="parentId"> | |
</div> | |
<div class="form-group"> | |
<label >用户ID</label> | |
<input class="form-control" id="userId" > | |
</div> | |
<button type="submit" class="btn btn-default">提交</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def retry(f, n_attempts=3): | |
# 包装函数,在函数异常时尝试多次调用,这里是尝试3次 | |
def wrapper(*args, **kwargs): | |
for i in range(n_attempts): | |
try: | |
return f(*args, **kwargs) | |
except Exception: | |
if i == n_attempts - 1: | |
raise | |
return wrapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ubuntu@iZwz92no3ygwxhh603stndZ:$ netstat -anutp | grep 9798 | grep LISTEN | |
(Not all processes could be identified, non-owned process info | |
will not be shown, you would have to be root to see it all.) | |
tcp 0 0 0.0.0.0:9798 0.0.0.0:* LISTEN 11944/python | |
ubuntu@iZwz92no3ygwxhh603stndZ:$ kill 11944 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def initMySQL(): | |
''' | |
链接mysql | |
:return: | |
''' | |
mysql_options = dict( | |
host="127.0.0.1", | |
db="数据表名称", | |
port=3306, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#先取出所有 keys,再对 keys 切片,然后用得到的键去字典里找值重新创建一个新的字典 | |
def dict_slice(adict, start, end): | |
keys = adict.keys() | |
dict_slice = {} | |
for k in keys[start:end]: | |
dict_slice[k] = adict[k] | |
return dict_slice | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
.demo-placeholder { | |
height: 280px | |
} | |
</style> | |
<!--折线图会出现到这里--> | |
<div class="col-md-12 col-sm-12 col-xs-12"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var onLoginSuccess = function (data) { | |
location.reload(); | |
} | |
$("#changemaintain").click(function(){ | |
var p = $('#changemaintain').val(); | |
if(p == '0'){ | |
p = '1'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="gameroomall"> | |
<div class="gameroomayu"> | |
</div> | |
</div> | |
function onAdd(){ | |
var configTable = $('.gameroomall'); | |
var num = parseInt(configTable.find('.gameroomayu').length); | |
if (num == 8){ | |
//信息框,使用了layer插件,google搜layer.js导入layer.js和layer.css则可使用 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from captcha.image import ImageCaptcha # pip install captcha | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from PIL import Image | |
import random | |
# 验证码中的字符, 就不用汉字了 | |
number = ['0','1','2','3','4','5','6','7','8','9'] | |
alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] | |
ALPHABET = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] |
OlderNewer