How to Strip Python Output

259 Views Asked by At

I want to strip platform.linux_distribution().

Output is tuple ('Ubuntu', '11.10', 'oneiric') but I want to show it as "Ubuntu 11.10 oneriric"

.group(1) is not working.

3

There are 3 best solutions below

0
On BEST ANSWER

You're looking for " ".join():

>>> import platform
>>> platform.linux_distribution()
('Ubuntu', '11.04', 'natty')
>>> " ".join(platform.linux_distribution())
'Ubuntu 11.04 natty'
>>> 
0
On

How about this:

" ".join(platform.linux_distribution())
0
On

how about:

' '.join(platform.linux_distribution())

I'm on a mac, so I don't have platform.linux_distribution(), but it looks like it should return an array.