只要结构总是一样的,这样的东西应该可以正常工作。
s = "GET /phpmyadmin HTTP/1.1"
matches = re.match( r'(.*) (.*) (.*)/(.*)', s, re.M|re.I)
ans = list(matches.groups())
阅读regex可能会有所帮助:
https://www.tutorialspoint.com/python/python_reg_expressions.htm
.
编辑:我同意上面的说法,你不同意
需要
一个正则表达式,但它比拆分和列表理解更漂亮。