使用正则提取里面的url'"background-image: url("https://static.geetest.com/nerualpic/space_l1_zh_2019.07.17/space/1e17b1dfc08a852158695a1d813e86be.jpg?challenge=f9b89219d4e6c3a58411cd3dba22ae74"); background-size: 100%; background-repeat: no-repeat;"'
时间: 2024-02-03 09:03:50 浏览: 234
你可以使用以下正则表达式来提取该字符串中URL:
```python
import re
= 'background-image: url("https://.geetest.com/nerual/space_l1_zh_2019.07.17/space/1e17b1dfc08a852158695a1d813e86be.jpg?challenge=f9b89219d4e6c3a58411cd3dba22ae74"); background-size: 100%; background-repeat: no-repeat;'
url = re.findall('url\("([^"]+)"\)', string)[0]
print(url)
```
这将输出:
```
https://static.geetest.com/nerualpic/space_l1_zh_2019.07.17/space/1e17b1dfc08a852158695a1d813e86be.jpg?challenge=f9b89219d4e6c3a58411cd3dba22ae74
```
阅读全文