回答編集履歴
3
追記
test
CHANGED
@@ -11,3 +11,15 @@
|
|
11
11
|
|
12
12
|
|
13
13
|
bを作るときのdecodeもやめて、bytesのまま取り出してからsliceしてdecodeの方が手っ取り早いかも。
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
```python
|
18
|
+
|
19
|
+
>>> b = binascii.unhexlify("0300002f2ae00000000000436f6f6b69653a206d737473686173683d41646d696e697374720d0a0100080003000000")
|
20
|
+
|
21
|
+
>>> b[b.find(b"Cookie"):b.find(b"\r\n")].decode()
|
22
|
+
|
23
|
+
'Cookie: mstshash=Administr'
|
24
|
+
|
25
|
+
```
|
2
修正
test
CHANGED
@@ -4,6 +4,10 @@
|
|
4
4
|
|
5
5
|
print(b[b.find("Cookie"):b.find("\r\n")]) # Cookie~改行まででスライス
|
6
6
|
|
7
|
-
# =>
|
7
|
+
# => Cookie: mstshash=Administr
|
8
8
|
|
9
9
|
```
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
bを作るときのdecodeもやめて、bytesのまま取り出してからsliceしてdecodeの方が手っ取り早いかも。
|
1
追記
test
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
b = binascii.unhexlify("0300002f2ae00000000000436f6f6b69653a206d737473686173683d41646d696e697374720d0a0100080003000000").decode("utf-8-sig",errors="backslashreplace") # strに変換する必要はなし
|
4
4
|
|
5
|
-
b[b.find("Cookie"):b.find("\r\n")] # Cookie~改行まででスライス
|
5
|
+
print(b[b.find("Cookie"):b.find("\r\n")]) # Cookie~改行まででスライス
|
6
|
+
|
7
|
+
# => 'Cookie: mstshash=Administr'
|
6
8
|
|
7
9
|
```
|