Hallo, Gast!
Artikel über www date click:
Mark Needham. Learn how to process date parameters with the Python Click Library. Python: Click – Handling Date Parameter.
Klicken Sie hier für Www date click
I’ve been building a little CLI application using the Python Click Library, and I wanted to pass in a Date as a parameter. There’s more than one way to do this. Let’s first install the Click library: And now we’ll import our required libraries: Now we’ll create a sub command that takes two parameters: date-start and date-end . These parameters have the type DateTime , and we can pass a string in the format yyyy-mm-dd from the command line: We can execute this command by running the following: We only passed in date-start , which means date-end has defaulted to today’s date. The dates are correct, but we still have time information that we don’t want. We can get rid of that by calling the date function on those DateTime objects: Now let’s run the script again: Alternatively we can create our own Date type based on the DateTime type: And then we’ll add a new command that uses this parameter type: And now let’s call this sub command: About the author. I’m currently working on short form content at ClickHouse. I publish short 5 minute videos showing how to solve data problems on YouTube @LearnDataWithMark. I previously worked on graph analytics at Neo4j, where I also co-authored the O’Reilly Graph Algorithms Book with Amy Hodler.