zoukankan      html  css  js  c++  java
  • python之导入模块的方法

    一、导入标准库模块
    1、第一种方式:
    可以通过以下方法导入
    1 import time
    当使用时间模块的sleep方法时可以使用
    1 time.sleep(2)
    2、第二种方式:
    当只想使用sleep函数时,可以通过以下方法
    1 from time import sleep
    2 sleep(2)
     
     
    二、导入第三方库模块
    通过pip install xxxx 安装的模块,直接import即可加载
    1 import selenium

     直接使用其中的方法也是可以的

    1 from selenium import webdriver
    三、导入自定义模块
    1、第一种方式
    将多个脚本均放置在同一个文件夹下面
    通过import 文件名导入模块并且可调用其模块下的方法
     
    1 import fuction2
    2 x=fuction2.fu2(10)
    3 print(x)
    查看执行结果:
     

    2、第二种方式

    直接导入模块下的方法
    1 from fuction3 impo fu3
    2 y=fu3(10)
    3 print(y)
    查看执行结果:
     
  • 相关阅读:
    FastDFS的简单使用
    KindEditor的简单使用
    rpc
    SDS——动态字符串
    图的深度优先遍历和广度优先遍历
    innodb和myisam原理
    cap理论
    冒泡排序
    桥接模式
    适配器模式
  • 原文地址:https://www.cnblogs.com/mrwhite2020/p/12892205.html
Copyright © 2011-2022 走看看