forked from gil9red/SimplePyScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelloPython.py
More file actions
40 lines (27 loc) · 1006 Bytes
/
HelloPython.py
File metadata and controls
40 lines (27 loc) · 1006 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
__author__ = "ipetrash"
import argparse
from datetime import datetime, time
def main(namespace) -> None:
args = namespace.parse_args()
args.user = "Илья"
if args.user:
welcome = "Привет"
current = datetime.now().time()
if time(6) <= current < time(12):
welcome = "Доброе утро"
elif time(12) <= current < time(18):
welcome = "Добрый день"
elif time(18) <= current < time(23, 59, 59):
welcome = "Добрый вечер"
elif time(0) <= current < time(6):
welcome = "Доброй ночи"
print(f"{welcome}, {args.user}!")
else:
print("Привет, Python!")
def create_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(description="Hello World Example!")
parser.add_argument("--user", type=str, help=" user name.")
return parser
if __name__ == "__main__":
parser = create_parser()
main(parser)