【Python】Python 字符串操作

Backto Python Index


基础语法

实用函数

小栗子

微信公众号文章分享链接截取有效部分

wechat_article_share_url_cut.py

origin_url = r'https://mp.weixin.qq.com/s?__biz=MzI0MTcwODI2OQ==&mid=2247484655&idx=1&sn=efe478107473be1a0b4ce3f8fc863053&chksm=e906396dde71b07bc82256832920f277147bc41f73fed7df07bfc8b1581594a2bdb74914884f&mpshare=1&scene=1&srcid=09191db3nIPuMQWUyVdSYRvj&from=singlemessage&ascene=1&devicetype=android-26&version=2607023a&nettype=WIFI&abtest_cookie=BQABAAgACgALABIAEwAFAJ2GHgAjlx4AWZkeAGKZHgBsmR4AAAA%3D&lang=zh_CN&pass_ticket=3JOiGSHpFdxde5JzQTov4cRGTaE08lkflBRI3Ii%2BG5undW0YFiyujnrEmh9g9u6Y&wx_header=r';

end_index = origin_url.find('&chksm=')
print('\n')
print(origin_url[:end_index])
print('\n')

Ref

猜你喜欢

转载自blog.csdn.net/baishuo8/article/details/82793037