Python正则表达式练习

# 一. 判断字符串是否是全部小写(s1 = 'adkkdk' s2 = 'abc123efg')
# import re,time
# s1 = 'adkkdk'
# s2 = 'abc123efg'
# if re.findall('[a-z]*',s1):
# print('s1全部为小写')
# else :
# print('鬼才知道是不是小写')
# if not re.findall('d*',s2):#如果包含数字就不是全部小写
# print('s2全部为小写')
# else :
# print('鬼才知道是不是小写')
# print(time.ctime())
# Mon Feb 26 10:01:13 2018
# F:PythonPythonLeaningvenvScriptspython.exe F:/Python/PythonLeaning/测试专用文件夹/正则表达式练习.py
# s1全部为小写
# 鬼才知道是不是小写
#
# Process finished with exit code 0
#####################################################################################################
# 二. 首字母缩写词扩充
# 具体示例
# FEMA Federal Emergency Management Agency
# IRA Irish Republican Army
# DUP Democratic Unionist Party
# FDA Food and Drug Administration
# OLC Office of Legal Counsel
# 分析
# 缩写词  FEMA
# 分解为  F*** E*** M*** A***
# 规律   大写字母 + 小写(大于等于1个)+ 空格
# import time,re
# s1 = 'Federal Emergency Management Agency'
# s2 = 'Irish Republican Army'
# s3 = 'Democratic Unionist Party'
# s4 = 'Food and Drug Administration'
# s5 = 'Office of Legal Counsel'
# res = re.split('[^A-Z]+',s1)
# res1 = "".join(res)
# print(res1+'的扩展形式是: '+s1)
########################################################################################################
# F:PythonPythonLeaningvenvScriptspython.exe F:/Python/PythonLeaning/测试专用文件夹/正则表达式练习.py
# FEMA的扩展形式是:
# Federal Emergency Management Agency
# Process finished with exit code 0
###########################################################################################################


Win a contest, win a challenge
原文地址:https://www.cnblogs.com/pandaboy1123/p/8476907.html