openfund-core 0.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openfund/core/__init__.py +0 -0
- openfund/core/binance_tools/__init__.py +16 -0
- openfund/core/binance_tools/binance_tools.py +39 -0
- openfund/core/binance_tools/continuous_klines.py +147 -0
- openfund/core/factory.py +37 -0
- openfund/core/libs/__init__.py +6 -0
- openfund/core/libs/email_tools.py +56 -0
- openfund/core/libs/enums.py +507 -0
- openfund/core/libs/file_tools.py +13 -0
- openfund/core/libs/log_tools.py +45 -0
- openfund/core/libs/prepare_env.py +28 -0
- openfund/core/libs/time.py +14 -0
- openfund/core/libs/time_tools.py +22 -0
- openfund/core/openfund_old/__init__.py +0 -0
- openfund/core/openfund_old/continuous_klines.py +153 -0
- openfund/core/openfund_old/depth.py +92 -0
- openfund/core/openfund_old/historical_trades.py +123 -0
- openfund/core/openfund_old/index_info.py +67 -0
- openfund/core/openfund_old/index_price_kline.py +118 -0
- openfund/core/openfund_old/klines.py +95 -0
- openfund/core/openfund_old/klines_qrr.py +103 -0
- openfund/core/openfund_old/mark_price.py +121 -0
- openfund/core/openfund_old/mark_price_klines.py +122 -0
- openfund/core/openfund_old/ticker_24hr_price_change.py +99 -0
- openfund/core/pyopenfund.py +32 -0
- openfund/core/sample/__init__.py +1 -0
- openfund/core/sample/sample.py +20 -0
- openfund/core/sycu_exam/__init__.py +1 -0
- openfund/core/sycu_exam/exam.py +19 -0
- openfund/core/sycu_exam/random_grade_cplus.py +440 -0
- openfund/core/sycu_exam/random_grade_web.py +404 -0
- openfund_core-0.0.2.dist-info/LICENSE +201 -0
- openfund_core-0.0.2.dist-info/METADATA +66 -0
- openfund_core-0.0.2.dist-info/RECORD +35 -0
- openfund_core-0.0.2.dist-info/WHEEL +4 -0
@@ -0,0 +1,103 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
import csv
|
3
|
+
import time
|
4
|
+
import os
|
5
|
+
import sys
|
6
|
+
import schedule
|
7
|
+
|
8
|
+
curPath = os.path.abspath(os.path.dirname(__file__))
|
9
|
+
rootPath = os.path.split(curPath)[0]
|
10
|
+
sys.path.append(rootPath)
|
11
|
+
|
12
|
+
|
13
|
+
from datetime import datetime
|
14
|
+
from binance.um_futures import UMFutures
|
15
|
+
from binance.error import ClientError
|
16
|
+
from libs.time_tools import format_timestamp
|
17
|
+
from libs.file_tools import create_path
|
18
|
+
from libs import enums
|
19
|
+
from libs import email_tools
|
20
|
+
from libs.log_tools import Logger
|
21
|
+
|
22
|
+
nextTimeMin = 5
|
23
|
+
um_futures_client = UMFutures()
|
24
|
+
app = "klines_qrr"
|
25
|
+
logger = Logger(app).get_log()
|
26
|
+
# logger.basicConfig(
|
27
|
+
# format="%(asctime)s %(name)s:%(levelname)s:%(message)s",
|
28
|
+
# datefmt="%Y-%m-%d %H:%M:%S",
|
29
|
+
# level=logger.INFO,
|
30
|
+
# filename="{0}/{1}_{2}.log".format(
|
31
|
+
# log_path, app, format_timestamp(datetime.now().timestamp() * 1000)
|
32
|
+
# ),
|
33
|
+
# )
|
34
|
+
|
35
|
+
|
36
|
+
def job():
|
37
|
+
content = ""
|
38
|
+
dateTime = ""
|
39
|
+
threshold = 10
|
40
|
+
POOL = enums.NEW_SYMBOL_POLL
|
41
|
+
interval = enums.KLINE_INTERVAL_5MINUTE
|
42
|
+
|
43
|
+
for symbol in POOL:
|
44
|
+
logger.info(
|
45
|
+
"{} symbol 开始计算量比 ++++++++++++++++++++++++++++ ".format(symbol)
|
46
|
+
)
|
47
|
+
params = {"limit": 2}
|
48
|
+
listData = []
|
49
|
+
try:
|
50
|
+
listData = um_futures_client.klines(symbol, interval, **params)
|
51
|
+
except Exception as e:
|
52
|
+
print("Error:", e)
|
53
|
+
logger.error("UM_FUTURES_CLIENT:", e)
|
54
|
+
time.sleep(10)
|
55
|
+
continue
|
56
|
+
latestRecords = len(listData)
|
57
|
+
logger.info("1、{} 获取数据 {} 条记录...".format(symbol, latestRecords))
|
58
|
+
# 计算量比
|
59
|
+
if latestRecords > 0:
|
60
|
+
qrr = 0
|
61
|
+
vol1 = float(listData[0][5])
|
62
|
+
vol2 = float(listData[1][5])
|
63
|
+
if vol2 != 0.0:
|
64
|
+
qrr = round(float(listData[0][5]) / float(listData[1][5]), 1)
|
65
|
+
|
66
|
+
lastTime = format_timestamp(listData[1][6])
|
67
|
+
curTime = format_timestamp(listData[0][6])
|
68
|
+
|
69
|
+
logger.info(
|
70
|
+
"2、{0} {2} ~ {3} 量比 = {1} ".format(symbol, qrr, lastTime, curTime)
|
71
|
+
)
|
72
|
+
|
73
|
+
if qrr >= threshold:
|
74
|
+
content = content + "{0} 量比QRR={1}> {4} ({2}/{3}={1})\n".format(
|
75
|
+
symbol, qrr, vol1, vol2, threshold
|
76
|
+
)
|
77
|
+
dateTime = "在[{0} ~ {1}]:\n".format(lastTime, curTime)
|
78
|
+
|
79
|
+
logger.info("{} symbol --------------------------------- ".format(symbol))
|
80
|
+
|
81
|
+
if content != "":
|
82
|
+
content = dateTime + content
|
83
|
+
logger.info("content:\n{}".format(content))
|
84
|
+
repeat = 3
|
85
|
+
while repeat > 0:
|
86
|
+
try:
|
87
|
+
email_tools.mail("QRR", content)
|
88
|
+
logger.info("Sender @Mail =========================== ")
|
89
|
+
repeat = 0 # 成功发送重置
|
90
|
+
except Exception as e:
|
91
|
+
print("Mail_Error:", e)
|
92
|
+
logger.error("EMAIL_TOOLS:", e)
|
93
|
+
repeat = repeat - 1 # 失败情况下重试3次
|
94
|
+
|
95
|
+
else:
|
96
|
+
logger.info("No Send Msg!")
|
97
|
+
|
98
|
+
|
99
|
+
if __name__ == "__main__":
|
100
|
+
schedule.every(nextTimeMin).minutes.do(job)
|
101
|
+
logger.info("Schedule Starting min ...... ".format(nextTimeMin))
|
102
|
+
while True:
|
103
|
+
schedule.run_pending() # 运行所有可运行的任务
|
@@ -0,0 +1,121 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
import csv
|
3
|
+
import time
|
4
|
+
import os
|
5
|
+
import sys
|
6
|
+
import json
|
7
|
+
|
8
|
+
curPath = os.path.abspath(os.path.dirname(__file__))
|
9
|
+
rootPath = os.path.split(curPath)[0]
|
10
|
+
sys.path.append(rootPath)
|
11
|
+
|
12
|
+
|
13
|
+
from datetime import datetime
|
14
|
+
from binance.um_futures import UMFutures
|
15
|
+
from binance.error import ClientError
|
16
|
+
from libs.time_tools import format_timestamp, format_date, format_date_to
|
17
|
+
from libs.file_tools import create_path
|
18
|
+
from libs.prepare_env import get_path
|
19
|
+
from libs import enums
|
20
|
+
from libs.log_tools import Logger
|
21
|
+
|
22
|
+
data_path, log_path = get_path()
|
23
|
+
um_futures_client = UMFutures()
|
24
|
+
|
25
|
+
|
26
|
+
# 暂停秒数
|
27
|
+
sleepSec = 10
|
28
|
+
#
|
29
|
+
nextTimesSec = 0
|
30
|
+
|
31
|
+
app = "mark_price"
|
32
|
+
logger = Logger(app).get_log()
|
33
|
+
# fileName = "{}/{}_{}.log".format(
|
34
|
+
# log_path, app, format_timestamp(datetime.now().timestamp() * 1000)
|
35
|
+
# )
|
36
|
+
# logger.basicConfig(
|
37
|
+
# format="%(asctime)s %(name)s:%(levelname)s:%(message)s",
|
38
|
+
# datefmt="%Y-%m-%d %H:%M:%S",
|
39
|
+
# level=logger.INFO,
|
40
|
+
# filename=fileName,
|
41
|
+
# )
|
42
|
+
|
43
|
+
latestRecords = 1
|
44
|
+
records = 0 # 累计记录数
|
45
|
+
queryTimes = 0 # 执行次数
|
46
|
+
errorCount = 0 # 异常次数
|
47
|
+
while True:
|
48
|
+
queryTimes = queryTimes + 1
|
49
|
+
logger.info("{} app 开始 ++++++++++++++++++++++++++++ ".format(app))
|
50
|
+
logger.info("1、第{}次开始执行...".format(queryTimes))
|
51
|
+
listData = []
|
52
|
+
try:
|
53
|
+
listData = um_futures_client.mark_price()
|
54
|
+
except KeyError as err:
|
55
|
+
print("KeyError:", err)
|
56
|
+
logger.error(err)
|
57
|
+
break
|
58
|
+
except ClientError as error:
|
59
|
+
logger.error(
|
60
|
+
"Found error. status: {}, error code: {}, error message: {}".format(
|
61
|
+
error.status_code, error.error_code, error.error_message
|
62
|
+
)
|
63
|
+
)
|
64
|
+
if error.error_code == -4144 and error.status_code == 400:
|
65
|
+
break
|
66
|
+
except Exception as e:
|
67
|
+
print("Error:", e)
|
68
|
+
logger.error(e)
|
69
|
+
errorCount = errorCount + 1
|
70
|
+
if errorCount > errorLimit:
|
71
|
+
break
|
72
|
+
else:
|
73
|
+
time.sleep(sleepSec)
|
74
|
+
continue
|
75
|
+
|
76
|
+
latestRecords = len(listData)
|
77
|
+
records = latestRecords + records
|
78
|
+
logger.info("2、{}条写入文件...".format(latestRecords))
|
79
|
+
|
80
|
+
path = "{}/{}/".format(data_path, app)
|
81
|
+
create_path(path) # 不存在路径进行呢创建
|
82
|
+
|
83
|
+
with open(
|
84
|
+
"{}{}_{}.csv".format(
|
85
|
+
path,
|
86
|
+
app,
|
87
|
+
# format_date_to(queryTimes)
|
88
|
+
format_date(datetime.now().timestamp() * 1000),
|
89
|
+
),
|
90
|
+
"a",
|
91
|
+
newline="",
|
92
|
+
) as file:
|
93
|
+
fieldnames = [
|
94
|
+
"symbol",
|
95
|
+
"markPrice",
|
96
|
+
"indexPrice",
|
97
|
+
"estimatedSettlePrice",
|
98
|
+
"lastFundingRate",
|
99
|
+
"interestRate",
|
100
|
+
"nextFundingTime",
|
101
|
+
"time",
|
102
|
+
]
|
103
|
+
writer = csv.DictWriter(file, fieldnames=fieldnames)
|
104
|
+
writer.writeheader()
|
105
|
+
for row in sorted(listData, key=lambda x: x["symbol"]):
|
106
|
+
writer.writerow(row)
|
107
|
+
|
108
|
+
logger.info("3、{} 抓取数据 {} 条记录...".format(app, records))
|
109
|
+
if latestRecords > 0:
|
110
|
+
nextFundingTime = listData[0]["nextFundingTime"]
|
111
|
+
curTime = listData[0]["time"]
|
112
|
+
# 计算下次刷新数据时间,作为执行周期
|
113
|
+
nextTimesSec = (nextFundingTime - curTime) // 1000 + 50
|
114
|
+
errorCount = 0
|
115
|
+
logger.info(
|
116
|
+
"4、下次执行时间 {} {}".format(
|
117
|
+
format_timestamp(nextFundingTime), nextFundingTime
|
118
|
+
)
|
119
|
+
)
|
120
|
+
logger.info("{} app 结束 --------------------------------- ".format(app))
|
121
|
+
time.sleep(nextTimesSec)
|
@@ -0,0 +1,122 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
import csv
|
3
|
+
import logging
|
4
|
+
import time
|
5
|
+
import os
|
6
|
+
import sys
|
7
|
+
|
8
|
+
curPath = os.path.abspath(os.path.dirname(__file__))
|
9
|
+
rootPath = os.path.split(curPath)[0]
|
10
|
+
sys.path.append(rootPath)
|
11
|
+
|
12
|
+
|
13
|
+
from datetime import datetime
|
14
|
+
from binance.um_futures import UMFutures
|
15
|
+
from binance.error import ClientError
|
16
|
+
from libs.time_tools import format_timestamp
|
17
|
+
from libs.file_tools import create_path
|
18
|
+
from libs.prepare_env import get_api_key, get_path
|
19
|
+
from libs import enums
|
20
|
+
|
21
|
+
data_path, log_path = get_path()
|
22
|
+
um_futures_client = UMFutures()
|
23
|
+
|
24
|
+
POOL = enums.CUR_SYMBOL_POOL
|
25
|
+
interval = enums.KLINE_INTERVAL_5MINUTE
|
26
|
+
# 历史截止数据开关
|
27
|
+
hisSwitch = 0
|
28
|
+
# hisSwitch 打开的情况下,抓取数据截止时间
|
29
|
+
hisDateTime = 1653974399999
|
30
|
+
# 发现异常后累计失败次数上限,超过后退出。
|
31
|
+
errorLimit = 100
|
32
|
+
# 异常后暂停秒数
|
33
|
+
sleepSec = 10
|
34
|
+
|
35
|
+
app = "mark_price_klines"
|
36
|
+
|
37
|
+
for symbol in POOL:
|
38
|
+
fileName = "{}/{}_{}_{}.log".format(
|
39
|
+
log_path, symbol, app, format_timestamp(datetime.now().timestamp() * 1000)
|
40
|
+
)
|
41
|
+
logging.basicConfig(
|
42
|
+
format="%(asctime)s %(name)s:%(levelname)s:%(message)s",
|
43
|
+
datefmt="%Y-%m-%d %H:%M:%S",
|
44
|
+
level=logging.INFO,
|
45
|
+
filename=fileName,
|
46
|
+
)
|
47
|
+
logging.info("{}_symbol 开始 ++++++++++++++++++++++++++++ ".format(symbol))
|
48
|
+
|
49
|
+
latestRecords = 1
|
50
|
+
records = 0 # 累计记录数
|
51
|
+
queryTimes = 0 # 执行次数
|
52
|
+
nextEndTime = 0 # 下次结束时间
|
53
|
+
errorCount = 0 # 异常次数
|
54
|
+
params = {"limit": 1000}
|
55
|
+
while latestRecords != 0: # 循环读取,直到记录为空
|
56
|
+
queryTimes = queryTimes + 1
|
57
|
+
if nextEndTime != 0:
|
58
|
+
params = {"limit": 1000, "endTime": nextEndTime}
|
59
|
+
|
60
|
+
logging.info("1、{}第{}次开始执行...".format(symbol, queryTimes))
|
61
|
+
listData = []
|
62
|
+
try:
|
63
|
+
listData = um_futures_client.mark_price_klines(symbol, interval, **params)
|
64
|
+
except KeyError as err:
|
65
|
+
print("KeyError:", err)
|
66
|
+
logging.error(err)
|
67
|
+
break
|
68
|
+
except ClientError as error:
|
69
|
+
logging.error(
|
70
|
+
"Found error. status: {}, error code: {}, error message: {}".format(
|
71
|
+
error.status_code, error.error_code, error.error_message
|
72
|
+
)
|
73
|
+
)
|
74
|
+
if error.error_code == -4144 and error.status_code == 400:
|
75
|
+
break
|
76
|
+
except Exception as e:
|
77
|
+
print("Error:", e)
|
78
|
+
logging.error(e)
|
79
|
+
errorCount = errorCount + 1
|
80
|
+
if errorCount > errorLimit:
|
81
|
+
break
|
82
|
+
else:
|
83
|
+
time.sleep(sleepSec)
|
84
|
+
continue
|
85
|
+
|
86
|
+
latestRecords = len(listData)
|
87
|
+
records = latestRecords + records
|
88
|
+
logging.info("2、{}条写入文件...".format(latestRecords))
|
89
|
+
|
90
|
+
path = "{}/{}/{}/".format(data_path, app, symbol)
|
91
|
+
create_path(path) # 不存在路径进行呢创建
|
92
|
+
|
93
|
+
with open(
|
94
|
+
"{}{}_{}_{}.csv".format(path, app, symbol, interval),
|
95
|
+
"a",
|
96
|
+
newline="",
|
97
|
+
) as file:
|
98
|
+
writer = csv.writer(file)
|
99
|
+
# 时间戳倒序,插入文件尾部
|
100
|
+
writer.writerows(sorted(listData, key=lambda x: x[0], reverse=True))
|
101
|
+
|
102
|
+
# 拿到最后一条记录后,获取close时间戳,变为下一次截止时间戳
|
103
|
+
if latestRecords > 0:
|
104
|
+
nextEndTime = (
|
105
|
+
listData[0][0] - 1
|
106
|
+
) # -1 不和close时间戳相同,避免重新拉取重复数据
|
107
|
+
errorCount = 0
|
108
|
+
logging.info(
|
109
|
+
"3、下次结束时间 {} {}".format(
|
110
|
+
format_timestamp(nextEndTime), nextEndTime
|
111
|
+
)
|
112
|
+
)
|
113
|
+
|
114
|
+
if nextEndTime <= hisDateTime and hisSwitch == 1:
|
115
|
+
break
|
116
|
+
else:
|
117
|
+
logging.info("4、结束...")
|
118
|
+
|
119
|
+
# time.sleep(0.1)
|
120
|
+
|
121
|
+
logging.info("5、{} 抓取数据 {} 条记录...".format(symbol, records))
|
122
|
+
logging.info("{} symbol --------------------------------- ".format(symbol))
|
@@ -0,0 +1,99 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
import csv
|
3
|
+
import time
|
4
|
+
import os
|
5
|
+
import sys
|
6
|
+
import schedule
|
7
|
+
|
8
|
+
|
9
|
+
curPath = os.path.abspath(os.path.dirname(__file__))
|
10
|
+
rootPath = os.path.split(curPath)[0]
|
11
|
+
sys.path.append(rootPath)
|
12
|
+
|
13
|
+
|
14
|
+
from datetime import datetime
|
15
|
+
from binance.um_futures import UMFutures
|
16
|
+
from binance.error import ClientError
|
17
|
+
from libs.time_tools import format_timestamp, format_date, format_date_to
|
18
|
+
from libs.file_tools import create_path
|
19
|
+
from libs.prepare_env import get_api_key, get_path
|
20
|
+
from libs import enums
|
21
|
+
from libs.log_tools import Logger
|
22
|
+
|
23
|
+
|
24
|
+
data_path, log_path = get_path()
|
25
|
+
um_futures_client = UMFutures()
|
26
|
+
|
27
|
+
|
28
|
+
# 暂停秒数
|
29
|
+
sleepSec = 5
|
30
|
+
|
31
|
+
app = "ticker_24hr_price_change"
|
32
|
+
logger = Logger(app).get_log()
|
33
|
+
# fileName = "{}/{}_{}.log".format(
|
34
|
+
# log_path, app, format_timestamp(datetime.now().timestamp() * 1000)
|
35
|
+
# )
|
36
|
+
# logging.basicConfig(
|
37
|
+
# format="%(asctime)s %(name)s:%(levelname)s:%(message)s",
|
38
|
+
# datefmt="%Y-%m-%d %H:%M:%S",
|
39
|
+
# level=logging.INFO,
|
40
|
+
# filename=fileName,
|
41
|
+
# )
|
42
|
+
|
43
|
+
|
44
|
+
def job():
|
45
|
+
records = 0 # 累计记录数
|
46
|
+
logger.info("{} app 开始 ++++++++++++++++++++++++++++ ".format(app))
|
47
|
+
listData = []
|
48
|
+
|
49
|
+
try:
|
50
|
+
listData = um_futures_client.ticker_24hr_price_change()
|
51
|
+
except Exception as e:
|
52
|
+
print("Error:", e)
|
53
|
+
logger.error(e)
|
54
|
+
|
55
|
+
latestRecords = len(listData)
|
56
|
+
path = "{}/{}/".format(data_path, app)
|
57
|
+
create_path(path) # 不存在路径进行呢创建
|
58
|
+
with open(
|
59
|
+
"{}{}_{}.csv".format(
|
60
|
+
path,
|
61
|
+
app,
|
62
|
+
format_date(datetime.now().timestamp() * 1000),
|
63
|
+
),
|
64
|
+
"a",
|
65
|
+
newline="",
|
66
|
+
) as file:
|
67
|
+
fieldnames = [
|
68
|
+
"symbol",
|
69
|
+
"priceChange",
|
70
|
+
"priceChangePercent",
|
71
|
+
"weightedAvgPrice",
|
72
|
+
"lastPrice",
|
73
|
+
"lastQty",
|
74
|
+
"openPrice",
|
75
|
+
"highPrice",
|
76
|
+
"lowPrice",
|
77
|
+
"volume",
|
78
|
+
"quoteVolume",
|
79
|
+
"openTime",
|
80
|
+
"closeTime",
|
81
|
+
"firstId",
|
82
|
+
"lastId",
|
83
|
+
"count",
|
84
|
+
]
|
85
|
+
writer = csv.DictWriter(file, fieldnames=fieldnames)
|
86
|
+
writer.writeheader()
|
87
|
+
for row in sorted(listData, key=lambda x: x["symbol"]):
|
88
|
+
writer.writerow(row)
|
89
|
+
|
90
|
+
logger.info("2、{}条写入文件...".format(latestRecords))
|
91
|
+
|
92
|
+
logger.info("{} app 结束 --------------------------------- ".format(app))
|
93
|
+
|
94
|
+
|
95
|
+
if __name__ == "__main__":
|
96
|
+
schedule.every(sleepSec).seconds.do(job)
|
97
|
+
logger.info("Schedule Starting {0}sec ...... ".format(sleepSec))
|
98
|
+
while True:
|
99
|
+
schedule.run_pending() # 运行所有可运行的任务
|
@@ -0,0 +1,32 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
from typing import TYPE_CHECKING
|
4
|
+
from typing import Any
|
5
|
+
|
6
|
+
from poetry.core.pyproject.toml import PyProjectTOML
|
7
|
+
|
8
|
+
|
9
|
+
if TYPE_CHECKING:
|
10
|
+
from poetry.core.packages.project_package import ProjectPackage
|
11
|
+
from poetry.poetry import Poetry
|
12
|
+
from openfund.core.factory import Factory
|
13
|
+
|
14
|
+
|
15
|
+
class Openfund:
|
16
|
+
def __init__(self, poetry: Openfund) -> None:
|
17
|
+
self._poetry: Poetry = poetry
|
18
|
+
|
19
|
+
@property
|
20
|
+
def poetry(self) -> Poetry:
|
21
|
+
from pathlib import Path
|
22
|
+
|
23
|
+
if self._poetry is not None:
|
24
|
+
return self._poetry
|
25
|
+
|
26
|
+
project_path = Path.cwd()
|
27
|
+
|
28
|
+
self._poetry = Factory().create_poetry(
|
29
|
+
cwd=project_path,
|
30
|
+
)
|
31
|
+
|
32
|
+
return self._poetry
|
@@ -0,0 +1 @@
|
|
1
|
+
from .sample import *
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# sample.py
|
2
|
+
|
3
|
+
# create a variable in the module
|
4
|
+
sample_variable = "This is a string variable in the sample.py module"
|
5
|
+
|
6
|
+
# A function in the module
|
7
|
+
def say_hello(name):
|
8
|
+
return f"Hello, {name} welcome to this simple module."
|
9
|
+
|
10
|
+
# This is another function in the module
|
11
|
+
def add(a, b):
|
12
|
+
return f"{a} + {b} is = {a+b}"
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
# print(sample_variable)
|
19
|
+
# print(say_hello("小明"))
|
20
|
+
# print(add(2, 3))
|
@@ -0,0 +1 @@
|
|
1
|
+
from .exam import *
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# sample.py
|
2
|
+
|
3
|
+
# create a variable in the module
|
4
|
+
sample_variable = "This is a string variable in the sample.py module"
|
5
|
+
|
6
|
+
|
7
|
+
# A function in the module
|
8
|
+
def say_hello(name):
|
9
|
+
return f"Hello, {name} welcome to this simple module."
|
10
|
+
|
11
|
+
|
12
|
+
# This is another function in the module
|
13
|
+
def add(a, b):
|
14
|
+
return f"{a} + {b} is = {a+b}"
|
15
|
+
|
16
|
+
|
17
|
+
# print(sample_variable)
|
18
|
+
# print(say_hello("小明"))
|
19
|
+
# print(add(2, 3))
|