zoukankan      html  css  js  c++  java
  • 导入模块的2种方法

    模块其实就是计算机中的一个py文件,可以把一个模块导入到当前py程序中,以增强其功能。导入模块使用import命令。

    例如i

    mport math

    math.sqrt(9)

    In [7]: math
    math

    In [7]: math.sqrt(9)
    Out[7]: 3.0

    使用import math。这必须先写上模块名,然后写函数名。例如math.sqrt()

    另外一个方法,from math import sqrt。这种方法导入模块之后,就可以直接使用函数了。

    In [15]: from math import pow

    In [16]: pow(2,4)
    Out[16]: 16.0

  • 相关阅读:
    问题6-10
    7.19 1
    经济学人常见词汇清单
    英语广播原声听力100篇MP3及听力原文
    6.30.2018
    6.26
    6.26
    6.26
    6.25
    6.25
  • 原文地址:https://www.cnblogs.com/gdlinux/p/11336968.html
Copyright © 2011-2022 走看看