From 456f54ecc371ba222d358f8bb1138b930805fc99 Mon Sep 17 00:00:00 2001 From: yuhuifeng Date: Mon, 17 Jan 2022 13:41:38 +0800 Subject: [PATCH 1/2] logging commit --- .../\345\215\217\347\250\213/asyncio_1.py" | 10 ++++++++ .../\345\215\217\347\250\213/asyncio_2.py" | 16 +++++++++++++ .../\345\215\217\347\250\213/asyncio_3.py" | 23 +++++++++++++++++++ .../\345\215\217\347\250\213/asyncio_4.py" | 23 +++++++++++++++++++ yhf.py | 19 +++++++++++++++ 5 files changed, 91 insertions(+) create mode 100644 "python_module_note/\345\215\217\347\250\213/asyncio_1.py" create mode 100644 "python_module_note/\345\215\217\347\250\213/asyncio_2.py" create mode 100644 "python_module_note/\345\215\217\347\250\213/asyncio_3.py" create mode 100644 "python_module_note/\345\215\217\347\250\213/asyncio_4.py" create mode 100644 yhf.py diff --git "a/python_module_note/\345\215\217\347\250\213/asyncio_1.py" "b/python_module_note/\345\215\217\347\250\213/asyncio_1.py" new file mode 100644 index 0000000..e40e348 --- /dev/null +++ "b/python_module_note/\345\215\217\347\250\213/asyncio_1.py" @@ -0,0 +1,10 @@ +import asyncio + + +async def main(): + print(f"hello") + await asyncio.sleep(1) + print('world') + + +asyncio.run(main()) diff --git "a/python_module_note/\345\215\217\347\250\213/asyncio_2.py" "b/python_module_note/\345\215\217\347\250\213/asyncio_2.py" new file mode 100644 index 0000000..86385d4 --- /dev/null +++ "b/python_module_note/\345\215\217\347\250\213/asyncio_2.py" @@ -0,0 +1,16 @@ +import asyncio +import time + + +async def say_after(delay, what): + await asyncio.sleep(delay) + print(what) + + +async def main(): + print(f"started at {time.strftime('%X')}") + await say_after(1, 'hello') + await say_after(2, 'world') + print(f"finished at {time.strftime('%X')}") + +asyncio.run(main()) \ No newline at end of file diff --git "a/python_module_note/\345\215\217\347\250\213/asyncio_3.py" "b/python_module_note/\345\215\217\347\250\213/asyncio_3.py" new file mode 100644 index 0000000..15eb9f2 --- /dev/null +++ "b/python_module_note/\345\215\217\347\250\213/asyncio_3.py" @@ -0,0 +1,23 @@ +import asyncio +import time + + +async def say_after(delay, what): + await asyncio.sleep(delay) + print(what) + + +async def main(): + task1 = asyncio.create_task(say_after(1, 'hello')) + + task2 = asyncio.create_task(say_after(2, 'world')) + + print(f"started at {time.strftime('%X')}") + + await task1 + await task2 + + print(f"finished at {time.strftime('%X')}") + + +asyncio.run(main()) diff --git "a/python_module_note/\345\215\217\347\250\213/asyncio_4.py" "b/python_module_note/\345\215\217\347\250\213/asyncio_4.py" new file mode 100644 index 0000000..15eb9f2 --- /dev/null +++ "b/python_module_note/\345\215\217\347\250\213/asyncio_4.py" @@ -0,0 +1,23 @@ +import asyncio +import time + + +async def say_after(delay, what): + await asyncio.sleep(delay) + print(what) + + +async def main(): + task1 = asyncio.create_task(say_after(1, 'hello')) + + task2 = asyncio.create_task(say_after(2, 'world')) + + print(f"started at {time.strftime('%X')}") + + await task1 + await task2 + + print(f"finished at {time.strftime('%X')}") + + +asyncio.run(main()) diff --git a/yhf.py b/yhf.py new file mode 100644 index 0000000..5bc4c6b --- /dev/null +++ b/yhf.py @@ -0,0 +1,19 @@ +class Root(object): + def __init__(self): + self.x = '这是属性' + + def fun(self): + # print(self.x) + print('这是方法') + + +class A(Root): + def __init__(self): + super().__init__() + + print('实例化时执行') + + +test = A() # 实例化类 +test.fun() # 调用方法 +test.x # 调用属性 -- Gitee From c06e02a191f60acbcf959197a0d7f00a1d9fdbdb Mon Sep 17 00:00:00 2001 From: yuhuifeng Date: Thu, 20 Jan 2022 16:29:32 +0800 Subject: [PATCH 2/2] pyppeteer --- python_module_note/pyppeteer/pyppeteer_01.py | 18 ++++++++++++++++++ python_module_note/pyppeteer/pyppeteer_02.py | 0 2 files changed, 18 insertions(+) create mode 100644 python_module_note/pyppeteer/pyppeteer_01.py create mode 100644 python_module_note/pyppeteer/pyppeteer_02.py diff --git a/python_module_note/pyppeteer/pyppeteer_01.py b/python_module_note/pyppeteer/pyppeteer_01.py new file mode 100644 index 0000000..b159d77 --- /dev/null +++ b/python_module_note/pyppeteer/pyppeteer_01.py @@ -0,0 +1,18 @@ +""" +brief_introduction:简单通过pyppeteer来浏览百度首页进行截图保存 +:1、 +""" + +import asyncio +from pyppeteer import launch + + +async def main(): + browser = await launch() + page = await browser.newPage() + await page.goto('https://www.baidu.com/') + await page.screenshot({'path': 'example.png'}) + await browser.close() + + +asyncio.get_event_loop().run_until_complete(main()) diff --git a/python_module_note/pyppeteer/pyppeteer_02.py b/python_module_note/pyppeteer/pyppeteer_02.py new file mode 100644 index 0000000..e69de29 -- Gitee