当前位置:网站首页>将函数放在模块中
将函数放在模块中
2022-07-05 12:40:00 【南湖渔歌】
# ------------- compute.py ---------------------------
def add(x,y):
return x + y
def sub(x,y):
return x - y
def mul(x,y):
return x * y
def div(x,y):
return x / y
# ------------- main.py ---------------------------
import compute as cp
print(cp.add(3,5))
print(cp.sub(3,5))
print(cp.mul(3,5))
print(cp.div(3,5))
from compute import add,sub,mul,div
print(add(3,5))
print(sub(3,5))
print(mul(3,5))
print(div(3,5))
from compute import * # 不推荐
print(add(3,5))
print(sub(3,5))
print(mul(3,5))
print(div(3,5))
边栏推荐
- 激动人心!2022开放原子全球开源峰会报名火热开启!
- Taobao short videos are automatically released in batches without manual RPA open source
- OPPO小布推出预训练大模型OBERT,晋升KgCLUE榜首
- Taobao product details API | get baby SKU, main map, evaluation and other API interfaces
- SAP SEGW 事物码里的 ABAP 类型和 EDM 类型映射的一个具体例子
- Kotlin function
- 【云原生】Nacos中的事件发布与订阅--观察者模式
- jxl笔记
- Introduction to the principle of DNS
- Taobao order interface | order flag remarks, may be the most stable and easy-to-use interface
猜你喜欢
2021-12-21 transaction record
SAP self-development records user login logs and other information
I'm doing open source in Didi
How can non-technical departments participate in Devops?
前几年外包干了四年,秋招感觉人生就这样了..
RHCSA1
OPPO小布推出预训练大模型OBERT,晋升KgCLUE榜首
Annotation problem and hidden Markov model
From the perspective of technology and risk control, it is analyzed that wechat Alipay restricts the remote collection of personal collection code
Compilation principle reading notes (1/12)
随机推荐
RHCSA7
Kotlin函数
Database connection pool & jdbctemplate
[cloud native] event publishing and subscription in Nacos -- observer mode
2021.12.16-2021.12.20 empty four hand transaction records
逆波兰表达式
Simply take stock reading notes (1/8)
LeetCode20.有效的括号
Iterator details in list... Interview pits
UNIX socket advanced learning diary - advanced i/o functions
CF:A. The Third Three Number Problem【关于我是位运算垃圾这个事情】
Neural network of PRML reading notes (1)
#yyds干货盘点#js截取文件后缀名
Transactions from January 14 to 19, 2022
Research: data security tools cannot resist blackmail software in 60% of cases
Taobao short video, why the worse the effect
RHCSA1
Yyds dry inventory JS intercept file suffix
Taobao short videos are automatically released in batches without manual RPA open source
在家庭智能照明中应用的测距传感芯片4530A