当前位置:网站首页>Put functions in modules
Put functions in modules
2022-07-05 13:01:00 【South Lake Fishing Song】
# ------------- 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 * # Not recommended
print(add(3,5))
print(sub(3,5))
print(mul(3,5))
print(div(3,5))
边栏推荐
- 将函数放在模块中
- SAP SEGW 事物码里的 ABAP Editor
- 实战模拟│JWT 登录认证
- #yyds干货盘点#js截取文件后缀名
- Overflow toolbar control in SAP ui5 view
- SAP SEGW 事物码里的 ABAP 类型和 EDM 类型映射的一个具体例子
- Halcon template matching actual code (I)
- Actual combat simulation │ JWT login authentication
- Introduction aux contrôles de la page dynamique SAP ui5
- MySQL 巨坑:update 更新慎用影响行数做判断!!!
猜你喜欢
It's too convenient. You can complete the code release and approval by nailing it!
About the single step debugging of whether SAP ui5 floating footer is displayed or not and the benefits of using SAP ui5
RHCSA3
Compilation principle reading notes (1/12)
[cloud native] use of Nacos taskmanager task management
Leetcode20. Valid parentheses
【云原生】Nacos-TaskManager 任务管理的使用
MySQL 巨坑:update 更新慎用影响行数做判断!!!
Install rhel8.2 virtual machine
Transactions from January 6 to October 2022
随机推荐
实现 1~number 之间,所有数字的加和
Four common problems of e-commerce sellers' refund and cash return, with solutions
函数的默认参数&函数参数的多种方法
Transactions from December 27 to 28, 2021
《2022年中國銀行業RPA供應商實力矩陣分析》研究報告正式啟動
What is the difference between Bi software in the domestic market
Taobao flag insertion remarks | logistics delivery interface
It's too convenient. You can complete the code release and approval by nailing it!
946. 验证栈序列
NFT: how to make money with unique assets?
Halcon 模板匹配实战代码(一)
实战模拟│JWT 登录认证
奔跑,开路
Wechat enterprise payment to change access, open quickly
Pinduoduo flag insertion remarks API
阿里云SLB负载均衡产品基本概念与购买流程
Transactions from December 29, 2021 to January 4, 2022
谈谈我写作生涯的画图技巧
How do e-commerce sellers refund in batches?
Taobao, pinduoduo, jd.com, Doudian order & Flag insertion remarks API solution