Created
June 20, 2017 01:20
-
-
Save the5fire/d2d1fe3ec1408ba1e70bf68d791e0183 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding:utf-8 | |
data = """ | |
1)1) (integer) 4 | |
2) (integer) 1332222 | |
3) (integer) 13 | |
4) 1) "SET" | |
2) "database" | |
3) "Redis" | |
2)1) (integer) 4 | |
2) (integer) 1332222 | |
3) (integer) 13 | |
4) 1) "SET" | |
2) "database" | |
3) "Redis" | |
""" | |
commands = [] | |
params = [] | |
for line in data.split('\n'): | |
if line.strip(): | |
if not line.startswith(' ') and params: | |
commands.append(params[:]) | |
params = [] | |
params.append(line.split(')')[-1]) | |
commands.append(params) | |
print commands |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment