-1

When I print(some_var) in Python, the output resembles:

u"some-id-0\x03some-name-0\x03some-url-0\x02some-id-1\x03some-name-1\x03some-url-1\x02some-user-uuid\x03some-name\x03some-url.com\x02some-user-id\x03some_name\x03some-url.com"

Not familiar with unicode, I had expected and want the data to be in a list of lists: [["some-id-0", "some-name-0", "some-url-0"], ["some-id-1", "some-name-1", "some-url-1], etc]

How do I implement this in Python?

asked Sep 15, 2022 at 16:54

1 Answer 1

1

A list comprehension can generate the list of lists:

[part.split('\x03') for part in some_var.split('\x02')]

Which yields

[['some-id-0', 'some-name-0', 'some-url-0'], ['some-id-1', 'some-name-1', 'some-url-1'], ['some-user-uuid', 'some-name', 'some-url.com'], ['some-user-id', 'some_name', 'some-url.com']]
answered Sep 15, 2022 at 17:09
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.