python 判斷手機號碼和正整數
import re ''' 輸入手機號碼,判斷手機號碼是否為11位,是否為1開頭的數值 ''' def get_phone(): while True: phone = input('請輸入手機號碼:') if len(phone) == 11 and re.match(r'1\d{10}', phone): return phone else: print('請輸入11位的手機號') ''' 輸入數量,判斷數量是否為正整數 ''' def get_amount(): while True: amount = input('請輸入數量:') if amount.isdigit() and int(amount) >= 0: return amount else: print('請輸入正整數!')
相關推薦
python 判斷手機號碼和正整數
import re ''' 輸入手機號碼,判斷手機號碼是否為11位,是否為1開頭的數值 ''' def get_phone(): while True: phone = input('請輸入手機號碼:') if len(phone)
oracle儲存過程判斷手機號碼和固話
create or replace procedure get_Area_Phone(i_phoneNum in varchar2,--傳入號碼 o_phoneFlag
python - 判斷是否為正小數和正整數
urn logs str 是否 check 進行 count code log 判斷輸入的金額是否為正整數和正小數 def check_float(string): #支付時,輸入的金額可能是小數,也可能是整數 s = str(string) if
判斷是否是手機號碼和手機號碼的正則表示式
//是否是手機號碼 public static boolean isMobileNo(String mobiles){ String telRegex = "[1][34578]\\d{9}"; if(TextUtils.isEmpty(m
php正則判斷手機號碼的方法
判斷 想象 模式 php dump 符號表 博客 5.5 obi 用正則匹配手機號碼的時候, 我們先分析一下手機號碼的規律: 1. 手機號通常是11位的 2. 經常是1開頭 3. 第二個數字通常是34578這幾個數字, 2014.5.5日170號段的手機號開賣所以這裏多了
人生苦短,我學python之python+selenium 隨機生成手機號碼和身份證
count read delta selenium 隨機 urn etime 手機號 身份證號 # coding:utf-8import osimport randomimport randomimport stringimport timefrom datetime im
js 手機號碼和電話號碼正則校驗
bsp con return else 校驗 AS AR obi ret checkPhone() { var mobile = ‘‘; var tel = /^0\d{2,3}-?\d{7,8}$/; var phone = /^(
驗證正則表示式(一),同時驗證手機號碼和固定電話號碼
var reg=^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\d{8}$|^0\d{2,3}-?\d{7,8}$;//正則表示式 主要實現程式碼如下: function CheckPhone(number){
Android正則表示式判斷手機號碼的格式
判斷手機號碼是否正確的方法: public static boolean isPhone(String inputText) { Pattern p = Pattern.compile("
js正則表示式驗證手機號碼和郵箱
原生的js 1、目前的手機號碼段如下: 檢視最新號碼段 移動: 139 138 137 136 135 134 147 150 151 152 157 158 159 178 182 183 184 187 188 聯通: 130 131 132 155
python程式設計:輸入一個正整數判斷它是不是素數
輸入一個正整數判斷它是不是素數 from math import sqrt def main(): num = int(input('請輸入一個正整數: ')) end = int(sqrt(num)) is_prime = T
判斷手機號碼格式的正則表示式
(BOOL)isMobileNumber:(NSString *)mobileNum { /** * 手機號碼 * 移動:134[0-8],135,136,137,138,139,150,151,157,158,159,182,187,188 *
python的OS庫和正則表達式庫
特殊字符 see lena 字符串表 find 移動 沒有 忽略 eva 摘自:http://blog.chinaunix.net/uid-16360955-id-3351990.html 作留存學習 1.常用內置函數:(不用import就可以直接使用) hel
js 手機號碼簡單正則校驗
test 分代 開頭 cti back 簡單 mage 循環 格式 現在手機號碼的號段有如下幾種,包括17年新發出的三個(166,199,198)號段。 在一些項目註冊登錄或者其他中,涉及到手機號進行一個簡單的有效驗證,在前端先進行一個簡單的檢驗; 判斷字符串是否
js 驗證手機號碼和座機號碼
<script type="text/javascript"> function checkTel(tel) { var mobile = /^1[3|5|8]\d{9}$/ , phone = /^0\d{2,3}-?\d{7,8}$/; return mobile
java判斷手機號碼是哪個運營商
手機號碼校驗規則: /** * 中國電訊號碼格式驗證 手機段: 133,153,180,181,189,177,1700,173,199 **/ private static final String CHINA_TELECOM_PATTE
【演算法】判斷小於n的正整數中有幾個質數
這個演算法比較簡單,關鍵在於你怎麼判斷一個正整數是不是質數。這裡用的方法是,用小於它的正整數去除它,如果餘數有0出現,那說明它是質數,反之,它不是質數。關鍵在於,你這個小於它的整數取到哪裡,其實取到它的平方根,就足以說明問題了。#include <iostream>
java判斷字串是否為正整數
//1. public static boolean isNumeric(String string){ Pattern pattern = Pattern.compile("[0-9]*")
判斷手機型號和cpu型號
<span style="font-size:18px;">判斷手機型號:</span><span style="font-size:18px;">private boolean isUnusualPhone(){ try {
正則表示式匹配 整數和正整數
一、匹配規則* 表示前面的子表示式匹配0次或更多次?匹配前面的子表示式零次或一次,或指明一個非貪婪限定符。要匹配 ? 字元,請使用 \?\d 匹配數字+ 匹配前面的子表示式一次或多次。要匹配 + 字元,請使用 \+二、匹配程式碼function isInt(str)