mardi 5 juillet 2016

C# Escape on command line argument


I am trying to pass a string argument to a python script I am calling from C#. However, the argument is not being recognized but the script still runs. I believe I am not using the correct approach in using escape sequences. Here is my code:

String argss = "C:/My_Python_lib/happyBirthday.py 'joe'";

'joe' is my input argument to my python script. I don't know if it is more complex than just wrapping it in single quotes, but being a beginner, I'm not really sure. Any help would be appreciated. Thanks.

EDIT I have included my python code below to show the script since none of the suggested answers seem to be working. Could it be due to the way the function is being called?

'''Function with parameter.'''


def happyBirthday(person):
    print("Happy Birthday to you!")
    print("Happy Birthday to you!")
    print("Happy Birthday, dear " + person + ".")
    print("Happy Birthday to you!")

happyBirthday('Emily')
happyBirthday('Andre')

Aucun commentaire:

Enregistrer un commentaire