I want to include file name 'main.txt' in the subject for that I am passing file name from command line. but getting error in doing so
python sample.py main.txt #running python with argument msg['Subject'] = "Auto Hella Restart Report "sys.argv[1] #line where i am using that passed argument
Python Print Variable - String Concatenation: language = "Python" #Adding the language variable into a string print("Hello" +" "+ language +" "+ "World!") #Output - “Hello Python World!” While using this method, spaces are not added and you would have to manually add them and hence this method is not used very often.
In JavaScript, we can assign strings to a variable and use concatenation to combine the variable to another string. To concatenate a string, you add a plus sign+ between the strings or string variables you want to connect. let myPet = 'seahorse'; console.
I'm guessing that you meant to do this:
msg['Subject'] = "Auto Hella Restart Report " + sys.argv[1] # To concatenate strings in python, use ^
variable=" Hello..." print (variable) print("This is the Test File "+variable)
for integer type ...
variable=" 10" print (variable) print("This is the Test File "+str(variable))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With