Hello I have a string like this:
AdvancedHTMLParser (8.0.1)\nappdirs (1.4.3)\nbeautifulsoup4 (4.6.0)\nchardet (3.0.4)\nchrome-gnome-shell (0.0.0)\ncupshelpers (1.0)\ncycler (0.10.0)\nCython (0.27.3)
I want to split this in a list of tuples. So that each list items has a tuple with two values, the name and the version (without the brackets).
I was only able to split the string by newline but I don't know how to properly grab the numbers in the brackets etc Can someone explain me how I can do this?
EDIT :
I am trying to parse pip list local
def get_installed_modules(self):
data = subprocess.check_output(["pip", "list", "--local"])
result = [tuple(line.replace('(', '').replace(')', '').split())
for line in data.splitlines()]
print(result)
I have the project that I cant just split the string but it requires a byte like object...
TypeError: a bytes-like object is required, not 'str'