Day8_100days of Python coding

本文介绍了Python中如何导入和使用模块,包括`import module`、`from module import function`以及`import *`的方式。示例展示了如何导入`math`模块的`pi`和`floor`函数,并解释了函数参数的概念。此外,还讨论了如何重命名导入的模块以及选择性导入模块的内容。
摘要由CSDN通过智能技术生成

如何在python里插入module

Python import Statement - AskPythonicon-default.png?t=L9C2https://www.askpython.com/python/python-import-statement插入module 里的函数

from {module} import {class/function}
from collections import OrderedDict
from os import path
from math import pi
print(pi)

想重新定义import的部分

import math as M
print(M.pi)

想import 除了class和function以外的statement:

2. The import * Statement

All the methods and constants of a particular module can be imported using import * operator.

from math(the_name_of_module) import *

print(pi)

print(floor(3.15))

如果不想import全部,那就

from module_name import A

#如果想一次多个

from module_name import A,B

#如果一次所有

from module_name import*

Functions with inputs

Arguments&Paraments

def my_funtion(something):
    #Do this with something

something=123
#something--parameter(参数)
#123--argument(函数调用时候的实际参数)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值