diff --git a/python_module_note/pyppeteer/pyppeteer_01.py b/python_module_note/pyppeteer/pyppeteer_01.py new file mode 100644 index 0000000000000000000000000000000000000000..b159d777904165bccdc70d15d42e270873f58201 --- /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 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 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 0000000000000000000000000000000000000000..e40e348533e9c8593979bbbdb110131235d53f0a --- /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 0000000000000000000000000000000000000000..86385d4387c092fc542e6a22dbdd4cfd226e7e41 --- /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 0000000000000000000000000000000000000000..15eb9f2a14f513e9da526c3dd9f325bd1e5c4422 --- /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 0000000000000000000000000000000000000000..15eb9f2a14f513e9da526c3dd9f325bd1e5c4422 --- /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 0000000000000000000000000000000000000000..5bc4c6b7f05b91e500ff304deaf6ae37ca8f194e --- /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 # 调用属性