1

I run my Python scripts with python -m unittest discover command. I'd like to passing current time yyyymmddhhmmssas parameter into execution command.

How can do that?

2
  • 1
    Possible duplicate of Command Line Arguments In Python Commented Nov 12, 2015 at 7:55
  • actually, my question is to produce a runtime cuurrendate Commented Nov 12, 2015 at 8:00

1 Answer 1

1

If you want to sample the current time on the system running the puthon code, you can use datetime.datetime.now() (local time) or datetime.datetime.utcnow() (UTC).

Then you can format as string using .strftime("%Y%m%d%H%M%S").

Sign up to request clarification or add additional context in comments.

5 Comments

can i use it as a parameter?
To which function do you want to pass the parameter?
.strftime("%Y%m%d%H%M%S") that you presented
That's just the conversion from a datetime object into a string with yyyymmddHHMMSS format. But where does the date/time sting go? Which function needs the infomation?
i think i couldn't clear the question: i have multiple python files. i run with command that i presented in question. i need that because, i will use same parameter for several purposes in each class(as an id)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.