99999久久久久久亚洲,欧美人与禽猛交狂配,高清日韩av在线影院,一个人在线高清免费观看,啦啦啦在线视频免费观看www

熱線電話:13121318867

登錄
首頁大數(shù)據(jù)時代python常用內(nèi)置函數(shù)整理—反射
python常用內(nèi)置函數(shù)整理—反射
2020-07-03
收藏

函數(shù)是組織好的,能夠重復(fù)使用的,用來實現(xiàn)單一,或相關(guān)聯(lián)功能的代碼段。python提供了許多內(nèi)建函數(shù),這些函數(shù)提高了應(yīng)用的模塊性,和代碼的重復(fù)利用率。下面是小編整理的python內(nèi)建函數(shù)中的反射類,希望對各位學(xué)習(xí)python有所幫助。

callable(object)    檢查對象object是否可調(diào)用。

1、類是可以被調(diào)用的;

2、實例是不可以被調(diào)用的,除非類中聲明了__call__方法

classmethod()  1、注解,用來說明這個方式是個類方法;

2、類方法即可被類調(diào)用,也可以被實例調(diào)用;

3、類方法類似于Java中的static方法;

4、類方法中不需要有self參數(shù)

compile(source, filename,mode[, flags[, dont_inherit]])將source編譯為代碼或者AST對象。代碼對象能夠通過exec語句來執(zhí)行或者eval()進行求值。

1、參數(shù)source:字符串或者AST(Abstract Syntax Trees)對象;

2、參數(shù) filename:代碼文件名稱,如果不是從文件讀取代碼則傳遞一些可辨認(rèn)的值;

3、參數(shù)model:指定編譯代碼的種類??梢灾付?‘exec’,’eval’,’single’;

4、參數(shù)flag和dont_inherit:這兩個參數(shù)暫不介紹

dir([object])  1、不帶參數(shù)時,返回當(dāng)前范圍內(nèi)的變量、方法和定義的類型列表;

2、帶參數(shù)時,返回參數(shù)的屬性、方法列表;

3、如果參數(shù)包含方法__dir__(),該方法將被調(diào)用。當(dāng)參數(shù)為實例時;

4、如果參數(shù)不包含__dir__(),該方法將最大限度地收集參數(shù)信息

delattr(object, name)   刪除object對象名為name的屬性

eval(expression [, globals [, locals]])  計算表達(dá)式expression的值

execfile(filename [, globals [, locals]])   用法類似exec(),不同的是execfile的參數(shù)filename為文件名,而exec的參數(shù)為字符串。

filter(function, iterable)   構(gòu)造一個序列,等價于[ item for item in iterable if function(item)]。

1、參數(shù)function:返回值為True或False的函數(shù),可以為None;

2、參數(shù)iterable:序列或可迭代對象

getattr(object, name [, defalut])    獲取一個類的屬性

globals()   返回一個描述當(dāng)前全局符號表的字典

hasattr(object, name)   判斷對象object是否包含名為name的特性

hash(object)    如果對象object為哈希表類型,返回對象object的哈希值

id(object)    返回對象的唯一標(biāo)識

isinstance(object, classinfo)   判斷object是否是class的實例

issubclass(class, classinfo)  判斷是否是子類

len(s)   返回集合長度

locals()   返回當(dāng)前的變量列表

map(function, iterable, …)  遍歷每個元素,執(zhí)行function操作

memoryview(obj)   返回一個內(nèi)存鏡像類型的對象

next(iterator[, default])  類似于iterator.next()

object()  基類

property([fget[, fset[, fdel[, doc]]]])   屬性訪問的包裝類,設(shè)置后可以通過c.x=value等來訪問setter和getter

reduce(function, iterable[, initializer])  合并操作,從第一個開始是前兩個參數(shù),然后是前兩個的結(jié)果與第三個合并進行處理,以此類推

reload(module) 重新加載模塊

setattr(object, name, value)    設(shè)置屬性值

repr(object)   將一個對象變幻為可打印的格式

staticmethod  聲明靜態(tài)方法,是個注解

super(type[, object-or-type])    引用父類

type(object)   返回該object的類型

vars([object])   返回對象的變量,若無參數(shù)與dict()方法類似

bytearray([source [, encoding [, errors]]])  返回一個byte數(shù)組。

1、如果source為整數(shù),則返回一個長度為source的初始化數(shù)組;

2、如果source為字符串,則按照指定的encoding將字符串轉(zhuǎn)換為字節(jié)序列;

3、如果source為可迭代類型,則元素必須為[0 ,255]中的整數(shù);

4、如果source為與buffer接口一致的對象,則此對象也可以被用于初始化bytearray.

zip(*iterables) 從參數(shù)中的多個迭代器取元素組合一個新的迭代器

數(shù)據(jù)分析咨詢請掃描二維碼

若不方便掃碼,搜微信號:CDAshujufenxi

數(shù)據(jù)分析師資訊
更多

OK
客服在線
立即咨詢
客服在線
立即咨詢
') } function initGt() { var handler = function (captchaObj) { captchaObj.appendTo('#captcha'); captchaObj.onReady(function () { $("#wait").hide(); }).onSuccess(function(){ $('.getcheckcode').removeClass('dis'); $('.getcheckcode').trigger('click'); }); window.captchaObj = captchaObj; }; $('#captcha').show(); $.ajax({ url: "/login/gtstart?t=" + (new Date()).getTime(), // 加隨機數(shù)防止緩存 type: "get", dataType: "json", success: function (data) { $('#text').hide(); $('#wait').show(); // 調(diào)用 initGeetest 進行初始化 // 參數(shù)1:配置參數(shù) // 參數(shù)2:回調(diào),回調(diào)的第一個參數(shù)驗證碼對象,之后可以使用它調(diào)用相應(yīng)的接口 initGeetest({ // 以下 4 個配置參數(shù)為必須,不能缺少 gt: data.gt, challenge: data.challenge, offline: !data.success, // 表示用戶后臺檢測極驗服務(wù)器是否宕機 new_captcha: data.new_captcha, // 用于宕機時表示是新驗證碼的宕機 product: "float", // 產(chǎn)品形式,包括:float,popup width: "280px", https: true // 更多配置參數(shù)說明請參見:http://docs.geetest.com/install/client/web-front/ }, handler); } }); } function codeCutdown() { if(_wait == 0){ //倒計時完成 $(".getcheckcode").removeClass('dis').html("重新獲取"); }else{ $(".getcheckcode").addClass('dis').html("重新獲取("+_wait+"s)"); _wait--; setTimeout(function () { codeCutdown(); },1000); } } function inputValidate(ele,telInput) { var oInput = ele; var inputVal = oInput.val(); var oType = ele.attr('data-type'); var oEtag = $('#etag').val(); var oErr = oInput.closest('.form_box').next('.err_txt'); var empTxt = '請輸入'+oInput.attr('placeholder')+'!'; var errTxt = '請輸入正確的'+oInput.attr('placeholder')+'!'; var pattern; if(inputVal==""){ if(!telInput){ errFun(oErr,empTxt); } return false; }else { switch (oType){ case 'login_mobile': pattern = /^1[3456789]\d{9}$/; if(inputVal.length==11) { $.ajax({ url: '/login/checkmobile', type: "post", dataType: "json", data: { mobile: inputVal, etag: oEtag, page_ur: window.location.href, page_referer: document.referrer }, success: function (data) { } }); } break; case 'login_yzm': pattern = /^\d{6}$/; break; } if(oType=='login_mobile'){ } if(!!validateFun(pattern,inputVal)){ errFun(oErr,'') if(telInput){ $('.getcheckcode').removeClass('dis'); } }else { if(!telInput) { errFun(oErr, errTxt); }else { $('.getcheckcode').addClass('dis'); } return false; } } return true; } function errFun(obj,msg) { obj.html(msg); if(msg==''){ $('.login_submit').removeClass('dis'); }else { $('.login_submit').addClass('dis'); } } function validateFun(pat,val) { return pat.test(val); }