diff --git a/2024.01.16_GUAN_package_learning/common/example_of_timer.py b/2024.01.16_GUAN_package_learning/common/example_of_timer.py index 78c4fbc..da05f1e 100644 --- a/2024.01.16_GUAN_package_learning/common/example_of_timer.py +++ b/2024.01.16_GUAN_package_learning/common/example_of_timer.py @@ -2,10 +2,24 @@ import guan @guan.timer_decorator -def my_function(): +def test1(a, b): import time + print(a) time.sleep(2) - print('Run finished!') + print(b) + print('Run finished.') for _ in range(3): - my_function() \ No newline at end of file + test1(10, b=20) + +print() + +def test2(a, b): + import time + print(a) + time.sleep(2) + print(b) + print('Run finished.') + +for _ in range(3): + guan.timer(test2, 10, b=20) \ No newline at end of file diff --git a/2024.01.16_GUAN_package_learning/common/example_of_try_except.py b/2024.01.16_GUAN_package_learning/common/example_of_try_except.py new file mode 100644 index 0000000..899a713 --- /dev/null +++ b/2024.01.16_GUAN_package_learning/common/example_of_try_except.py @@ -0,0 +1,22 @@ +import guan + +def test1(a, b): + print(a) + bug_code + print(b) + return 'return_message1' + +result1 = guan.try_except(test1, 10, b=20) +print(result1) + +print() + +@guan.try_decorator +def test2(a, b): + print(a) + bug_code + print(b) + return 'return_message2' + +result2 = test2(100, b=200) +print(result2) \ No newline at end of file