通過python檢測字串的字母

2022-09-26 12:27:25 字數 519 閱讀 8873

**如下

# !/usr/bin/python3.4

# -*- coding: utf-8 -*-

import re

a = "8a2656"

b =程式設計客棧 "1514561a1321"

c = "15465461654"

d = "afgwgw"

r = re.compile(r'^[a-za-程式設計客棧z]')

for item in d:

result = r.match(item)

if result != none:

print("包含字母:" + result.group())

else:

print("不包含字母")

結果包含字母:a

包含字程式設計客棧母:f

包含字母:g

包含字母:w

包含字母:g

包含字母:wualqdhtpaq

本文標題: 通過python檢測字串的字母

本文位址:

檢測字串

instanceof 用來檢測某乙個例項是否屬於這個類 constructor 利用原型構造器的方式檢測資料型別 object.prototype.tostring.call 借用內建類object原型上的tostring方法實現資料型別檢測console.log typeof typeof typ...

Python 檢測字串的方法

語法 str.isalnum 返回值 如果 string 至少有乙個字元並且所有字元都是字母或數字則返回 true,否則返回 false str1 this2018 str2 hello world print str1.isalnum print str2.isalnum 例項輸出結果為 true...

python檢測字串是否是回文字串

coding utf 8 spyder editor author linguiyuan def reverse text return text 1 def ishuiwen text return text reverse text text input 輸入乙個字串判斷是否是回文字串 n if...