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

熱線電話:13121318867

登錄
首頁精彩閱讀這幾個Python小技巧你不得不知道
這幾個Python小技巧你不得不知道
2022-06-01
收藏
這幾個Python小技巧你不得不知道

CDA數(shù)據(jù)分析師 出品

編輯:Mika

Python 之變量的命名

大家好,這一期 Python 小技巧,我們來講一講變量的命名。

有這么幾個規(guī)則你一定要注意:

一、不可以使用數(shù)字來開頭。

你看如果是數(shù)字開頭,運行就是錯的。

這幾個Python小技巧你不得不知道

二、不可以有空格。

你看 abc 和 1 之間不能有空格,你至少要用一個下劃線或者橫線來命名,當然我推薦下劃線。

這幾個Python小技巧你不得不知道

三、不可以使用內(nèi)置函數(shù)。

比如說 print ,本身就是一個打印的函數(shù),你不要把它當做變量來用。用了之后,打印的功能就沒了。

這幾個Python小技巧你不得不知道

四、不可以使用關(guān)鍵字。

像 for 等關(guān)鍵字不能用,因為它已經(jīng)被賦予了該有的意義了,你記住了嗎?

這幾個Python小技巧你不得不知道

Python 之獲取輸入的內(nèi)容

接著,我們來講講 Python 如何獲取輸入的內(nèi)容。

我們使用 input 這個內(nèi)置函數(shù)來獲取輸入的內(nèi)容。

大家可以看到,我們運行一下。

這里輸入想輸入內(nèi)容,這里寫上我的名字 david 回車。

這時候 david 這個詞已經(jīng)復(fù)制給了 your name,所以我現(xiàn)在再把 your name 打印出來看一下。

你看, david 就在這里顯示了,所以 input 就是用來獲取你想要輸入內(nèi)容的一個內(nèi)置方法。

這幾個Python小技巧你不得不知道

你學(xué)會了嗎?

Python 之 if 循環(huán)

大家好,在 Python 里有一個非常重要的 if 循環(huán)需要我們掌握。

我們今天就來講一下。

首先我這里有一個 x 等于 10 ,我先寫一個 if x < 5,那就 print 年齡小于 5 ,elif 代表如果 if 不滿足的話,接下來繼續(xù)判斷這個是否滿足。

x 是不是大于等于 5 小于 15 ,如果在這個范圍里就 print 年齡大于等于5歲小于15歲。

最后如果這兩個都不滿足 else ,print 年齡大于15歲。

這里我們就可以看一下,如果 x 等于 10,在這個 if 循環(huán)里會得到的結(jié)果就是:年齡大于等于5歲小于15歲。

如果改成 20 ,它就會運行得到的結(jié)果是年齡大于15歲。

這幾個Python小技巧你不得不知道

這個 if 循環(huán)非常重要,需要同學(xué)們好好掌握。

數(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); }