码迷,mamicode.com
首页 > 编程语言 > 详细

python基础学习日志day5

时间:2017-05-09 21:38:59      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:介绍   util   sys.path   路径   正则表达式   内容   tor   函数   from   

学习内容

  1. 模块介绍
  2. time &datetime模块
  3. random
  4. os
  5. sys
  6. shutil
  7. json & picle
  8. shelve
  9. xml处理
  10. yaml处理
  11. configparser
  12. hashlib
  13. subprocess
  14. logging模块
  15. re正则表达式

一:模块介绍  

  模块分为三种:

  • 自定义模块
  • 内置标准模块(又称标准库)
  • 开源模块

自定义模块使用

# -*- coding:utf-8 -*-
__author__ = shisanjun
"""
day4和day5在同级目录下
test2在目录day5下面,需要调用在day4.decorator1下index函数
"""
import os
import sys

"""
    os.path.abspath(__file__):文件所在的绝对路径
    os.path.dirname(os.path.abspath(__file__)):文件所在上级目录
    os.path.dirname(os.path.dirname(os.path.abspath(__file__))):文件所在上上级目录(可以调用day4,day5)
"""

BASE_DIR=os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(BASE_DIR) #将上上级目录加入系统目录环境
from  day4.decorator1 import index #如果没有上面两个步骤,导入的模块会报no moulde

index()

二:time &datetime模块

  1)time模块使用方法

    

python基础学习日志day5

标签:介绍   util   sys.path   路径   正则表达式   内容   tor   函数   from   

原文地址:http://www.cnblogs.com/lixiang1013/p/6832475.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!