Skip to content

Instantly share code, notes, and snippets.

@the5fire
Created June 20, 2017 01:20
Show Gist options
  • Save the5fire/d2d1fe3ec1408ba1e70bf68d791e0183 to your computer and use it in GitHub Desktop.
Save the5fire/d2d1fe3ec1408ba1e70bf68d791e0183 to your computer and use it in GitHub Desktop.
# 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