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
#coding=utf-8 | |
import xlrd | |
class ExcelLibrary(): | |
def open_excel_sheet(self,filename,sheetname="Sheet1"): | |
bk=xlrd.open_workbook(filename) | |
table=bk.sheet_by_name(sheetname) | |
return table | |
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
/** | |
* 修改XMLHttpRequest发送方法,更改Ajax目标url | |
*/ | |
XMLHttpRequest.prototype._open = XMLHttpRequest.prototype.open; | |
XMLHttpRequest.prototype.open = function(method, url, async) { | |
// 用对象便于修改参数 | |
var options = { | |
method: method, | |
url: url, | |
async: async |
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
(function($){ | |
//备份jquery的ajax方法 | |
var _ajax=$.ajax; | |
//重写jquery的ajax方法 | |
$.ajax=function(opt){ | |
//opt.jsonp = 'callbackparam'; | |
//opt.jsonpCallback="printMockLog"; | |
//opt.dataType = 'jsonp'; | |
//opt.url='http://127.0.0.1:8000/myjsonp/getPumsData?url='+opt.url; |
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
#usage http://auto.58corp.com:9011/ | |
if __name__ == '__main__': | |
import socket | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
sock.bind(('', 9011)) | |
sock.listen(5) | |
while True: | |
connection,address = sock.accept() | |
try: | |
connection.settimeout(5) |
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
#decoding:utf-8 | |
from selenium import webdriver | |
from selenium.common.exceptions import NoSuchElementException | |
from selenium.webdriver.common.keys import Keys | |
import time | |
import cv2.cv as cv | |
browser = webdriver.Firefox() # Get local session of firefox | |
browser.get("http://www.baidu.com") # Load page |
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
//触发onchange事件 | |
$('#my_id').val('3').trigger('change'); | |
//动态添加元素后重新初始化列表 | |
$(tr).find('.select-source').next().remove(); | |
$(tr).find('.select-source').select2({ | |
minimumResultsForSearch: Infinity | |
}); |
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
//只能输入数字 | |
$(document).on('keypress','input[type=number]',function(e){ | |
var e = e || window.event; | |
if (e.keyCode >= 48 && e.keyCode <= 57) | |
{ | |
e.returnValue = true; | |
} else { | |
e.preventDefault(); | |
} | |
}); |