"cookie: Authorization=0gfxJNnth53HLyHkUx4D9F2c8C0lfOmR8WFWxxj4nf5VoHqnr6ZYGbGQoBcd2g1tHqPGS3ZfgVgFJWzFhgdNQXdbxF8alKBkCH32IDzBoNyBVIgXkSpBBk6P0aFNKj2Y; Max-Age=21600; Expires=Wed, 24 May 2023 02:11:41 +0800; Path=/ "这个字符串用python正则提取出0gfxJNnth53HLyHkUx4D9F2c8C0lfOmR8WFWxxj4nf5VoHqnr6ZYGbGQoBcd2g1tHqPGS3ZfgVgFJWzFhgdNQXdbxF8alKBkCH32IDzBoNyBVIgXkSpBBk6P0aFNKj2Y
时间: 2023-12-03 22:43:35 浏览: 82
H3CNE-Security安全(GB0-510)题库13-4.docx
可以使用Python中的re模块来提取字符串中的Authorization值。示例代码如下:
```python
import re
string = 'cookie: Authorization=0gfxJNnth53HLyHkUx4D9F2c8C0lfOmR8WFWxxj4nf5VoHqnr6ZYGbGQoBcd2g1tHqPGS3ZfgVgFJWzFhgdNQXdbxF8alKBkCH32IDzBoNyBVIgXkSpBBk6P0aFNKj2Y; Max-Age=21600; Expires=Wed, 24 May 2023 02:11:41 +0800; Path=/'
match = re.search(r'Authorization=([\w\d]+)', string)
if match:
authorization = match.group(1)
print(authorization)
else:
print('Authorization value not found in string')
```
这个代码将输出"0gfxJNnth53HLyHkUx4D9F2c8C0lfOmR8WFWxxj4nf5VoHqnr6ZYGbGQoBcd2g1tHqPGS3ZfgVgFJWzFhgdNQXdbxF8alKBkCH32IDzBoNyBVIgXkSpBBk6P0aFNKj2Y"。
阅读全文