首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >python 字符串开头结尾匹配

python 字符串开头结尾匹配

作者头像
用户5760343
发布于 2022-01-10 08:44:10
发布于 2022-01-10 08:44:10
2.4K0
举报
文章被收录于专栏:sktjsktj

filename = 'spam.txt' filename.endswith('.txt') True filename.startswith('file:') False url = 'http://www.python.org' url.startswith('http:') True

或者正则

import re url = 'http://www.python.org' re.match('http:|https:|ftp:', url) <_sre.SRE_Match object at 0x101253098>

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019.09.24 ,如有侵权请联系 cloudcommunity@tencent.com 删除
目录
  • 或者正则
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档