From e1b7ca0a3b1b229a5155e4d7a0900dde4ec13fc6 Mon Sep 17 00:00:00 2001 From: dineshkumar2509 <54076851+dineshkumar2509@users.noreply.github.com> Date: Fri, 2 Oct 2020 13:32:22 +0530 Subject: [PATCH 1/3] Update args.py --- func/args.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/func/args.py b/func/args.py index 0299aaf..fb38377 100644 --- a/func/args.py +++ b/func/args.py @@ -11,9 +11,9 @@ def x(a, b, *c): # 参数前面为**, 代表这个位置的参数不知道有多少个参数, 如果有, 则将其存储为字典 def y(*c, **k): - print c - print k + print(c) + print(k) if __name__ == "__main__": x(1,2,3,4) - y(1,2,a="b",c="d") \ No newline at end of file + y(1,2,a="b",c="d") From 08611d830be696832a5d12de9471849a6fe9ef11 Mon Sep 17 00:00:00 2001 From: Akagi201 Date: Tue, 29 Aug 2023 21:45:47 +0800 Subject: [PATCH 2/3] feat: add asyncio --- asyncio/ccxt_async.py | 34 ++++++++++++++++++++++++++++++++++ asyncio/multi_tasks.py | 16 ++++++++++++++++ asyncio/simple.py | 8 ++++++++ 3 files changed, 58 insertions(+) create mode 100644 asyncio/ccxt_async.py create mode 100644 asyncio/multi_tasks.py create mode 100644 asyncio/simple.py diff --git a/asyncio/ccxt_async.py b/asyncio/ccxt_async.py new file mode 100644 index 0000000..d217141 --- /dev/null +++ b/asyncio/ccxt_async.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- + +import asyncio +import functools +import os +import sys + +root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +sys.path.append(root + '/python') + +import ccxt.async_support as ccxt # noqa: E402 + + +async def print_ticker(symbol, id): + # verbose mode will show the order of execution to verify concurrency + exchange = getattr(ccxt, id)({'verbose': True}) + print(await exchange.fetch_ticker(symbol)) + await exchange.close() + + +if __name__ == '__main__': + + symbol = 'ETH/BTC' + print_ethbtc_ticker = functools.partial(print_ticker, symbol) + [asyncio.ensure_future(print_ethbtc_ticker(id)) for id in [ + 'bitfinex', + 'poloniex', + 'kraken', + 'bittrex', + 'hitbtc', + ]] + loop = asyncio.get_event_loop() + pending = asyncio.all_tasks(loop) + loop.run_until_complete(asyncio.gather(*pending)) \ No newline at end of file diff --git a/asyncio/multi_tasks.py b/asyncio/multi_tasks.py new file mode 100644 index 0000000..ee081f1 --- /dev/null +++ b/asyncio/multi_tasks.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()) diff --git a/asyncio/simple.py b/asyncio/simple.py new file mode 100644 index 0000000..675b564 --- /dev/null +++ b/asyncio/simple.py @@ -0,0 +1,8 @@ +import asyncio + +async def main(): + print('Hello ...') + await asyncio.sleep(1) + print('... World!') + +asyncio.run(main()) From 5e019662040800e8997002d31588534093b79a43 Mon Sep 17 00:00:00 2001 From: Akagi201 Date: Thu, 16 May 2024 14:10:43 +0800 Subject: [PATCH 3/3] chore: delete file --- .../test_matplot-checkpoint.ipynb | 107 ------------------ 1 file changed, 107 deletions(-) delete mode 100644 ipython/.ipynb_checkpoints/test_matplot-checkpoint.ipynb diff --git a/ipython/.ipynb_checkpoints/test_matplot-checkpoint.ipynb b/ipython/.ipynb_checkpoints/test_matplot-checkpoint.ipynb deleted file mode 100644 index 5cb5fe5..0000000 --- a/ipython/.ipynb_checkpoints/test_matplot-checkpoint.ipynb +++ /dev/null @@ -1,107 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "from matplotlib.pyplot import *\n", - "from numpy import *\n", - "x = linspace(0, 2 * pi)\n", - "plot(x, sin(x), label=r'$\\sin(x)$')\n", - "plot(x, cos(x), 'ro', label=r'$\\cos(x)$')\n", - "title(r'Two familiar functions')\n", - "legend()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -}