Jim Charter
Jim Charter

Reputation: 3

How to Strip Python Output

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.

Upvotes: 0

Views: 251

Answers (3)

sarnold
sarnold

Reputation: 104080

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

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

Upvotes: 4

ObscureRobot
ObscureRobot

Reputation: 7336

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.

Upvotes: 0

Brendan Long
Brendan Long

Reputation: 54272

How about this:

" ".join(platform.linux_distribution())

Upvotes: 0

Related Questions