python - Default values for string format use in string (template) -


hope can me below problem have in python. trying use string format of template need how have default values.

template = """ server {isserverrunning} ntp {isntprunning} application {isapprunning} """  test = template.format(isserverrunning='is not running')  print test  output: server not running ntp running application running 

(lets default values 3 paramters should 'is running')

thanks time

can encase in function like:

def test(isserverrunning='is running',          isntprunning='is running',          isapprunning='is running'):           return template.format(              isserverrunning=isserverrunning,               isntprunning=isntprunning,               isapprunning=isapprunning) 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -