python-3.x - 确保字符串不包含链接的最佳方法是什么
问题描述
使用内置库确保字符串不包含链接 https:// 或 http:// 甚至只有地址(www.google.com)而不包含 http(s) 的最佳和干净的方法是什么
解决方案
写一个 if 语句就足够了:
str1="https://www.google.com"
keyword="https://"
if keyword in str1:
print("The chosen string contains a website link")
推荐阅读
- ios - MPSImageHistogramEqualization 抛出偏移量必须小于 [缓冲区长度] 的断言
- pandas - 数据可视化 Python
- mysql - 使用 laravel 获取外键详细信息
- flutter - 如何通过时间限制颤振上传和修剪视频
- ruby-on-rails - How do I use content_for
- vb.net - 如何修复(找不到文件)异常
- maven - Maven 发布分支失败,错误=7,参数列表太长
- c++ - 如何打印出 const 字符串的第一个元素?
- php - Assigning keys to an empty array
- ios - 如何判断是否有人取消了对我的 iOS 应用的订阅?