

Python 正则的问题 - V2EX
source link: https://www.v2ex.com/t/801288
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

部分代码:
ip = '1.2.3.4:8080/3xx3/a.php?b=1'
parse_obj = urlparse(ip)
print(parse_obj)
解析之后的结果:
ParseResult(scheme='1.2.3.4', netloc='', path='8080/3xx3/a.php', params='', query='b=1', fragment='')
请问各位大佬,针对这种不带 http(s)://的情况,如何使用正则提取 path 中的端口而不要之后路径呢,小白求解。
Recommend
-
101
Bitcoin - @nneedd - 公司电量免费充足,萌新想买两个矿机,搜索网贴推荐蚂蚁,一问:大家推荐啥?二问:蚂蚁的先汇款模式可能不发货么?
-
86
MacBook Pro - @yyn618 - 大家的 MBP 一般都是清理屏幕什么的 官方说的是无水绒布擦拭还有贴膜什么的有必要吗 我看贴键盘膜对屏幕可能不好 学设计的 有必要贴嘛 平时日常使用还是挺注意的
-
57
Windows - @youthcould - 对 Macbook 印象最好的一点是合上盖直接装包带走,基本不用关机。用 win10 ( xps 13 9360 )也这么干过,然后 2 小时候在包里烫的不行。不知道是不是自己设置的问题,网上搜索
-
18
Armin's Blog使用V2EX的CDN解决Gravatar加载慢问题August 04, 2016在主题的 function.php 中,在最后面添加: //replace Gravatar from V2EX function my_get_avatar( $avatar ) {...
-
5
V2EX › Python 请教一个 Python 正则问题,相同代码运行出来结果不一样了 karlxu · 1 天前 ·...
-
16
V2EX › Python Python logger 问题请教 zxCoder · 13 小时 44 分钟前 · 696 次点击
-
9
V2EX › Windows Windows Insider 过期问题 kanade · 4 小时 2 分钟前 · 269 次点击 ...
-
6
V2EX › Android 新版 Android Studio 全局搜索问题 prosixe · 23 小时 41 分钟前 · 466 次...
-
9
V2EX › Python Python 新手问题 huyan3280 · 11 小时 56 分钟前 · 477 次点击
-
5
V2EX › 宽带症候群 [求助] Chromium 系浏览器打开 V2EX 遇到的问题
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK