• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > Python中os.path用法分析

Python中os.path用法分析

作者:shichen2014 字体:[增加 减小] 来源:互联网

shichen2014 通过本文主要向大家介绍了python os.path,python os.path.join,python中os.path,python中os.path.join,python os.path.isdir等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

本文实例分析了Python中os.path用法。分享给大家供大家参考。具体如下:
import os
print os.path.abspath("d:\\new\\test.txt")
print os.path.basename("d:\\new\\test.txt")
print os.path.dirname("d:\\new\\test.txt")
print os.path.exists("d:\\new")
print os.path.lexists("d:\\new")
print os.path.expanduser("d:\\new\\text.txt")
print os.path.getatime("d:\\new")  #最后访问时间
print os.path.getmtime("d:\\new") #最后修改路径时间
print os.path.getctime("d:\\new")  #创建时间
print os.path.getsize("d:\\new\\")  #或许路径的大小 字节为单位
print os.path.isabs("d:\\")  #是否是绝对路径
print os.path.isfile("d:\\new\\hello.txt")
print os.path.isdir("d:\\new")
print os.path.islink("d:\\new\\hello.txt")
print os.path.join("d:\\new","hello.txt")
print os.path.normcase("d:\\new\\hello.txt")
print os.path.relpath("d:\\new\\hello.txt")  #相对路径
print os.path.split("d:\\new\\hello.txt")  #分离文件名
print os.path.splitdrive("d:\\new\\hello.txt")  #分离磁盘驱动器
print os.path.splitext("d:\\new\\hello.txt")  #分离扩展名</div>
  
运行结果:
>>>
d:\new\test.txt
test.txt
d:\new
True
True
d:\new\text.txt
1322235096.47
1322235096.47
1321610018.9
16384
True
True
True
False
d:\new\hello.txt
d:\new\hello.txt
hello.txt
('d:\\new', 'hello.txt')
('d:', '\\new\\hello.txt')
('d:\\new\\hello', '.txt')
>>>

希望本文所述对大家的Python程序设计有所帮助。

</div>

您可能想查找下面的文章:

  • Python中的os.path路径模块中的操作方法总结
  • Python中的os.path路径模块中的操作方法总结
  • python中列表元素连接方法join用法实例
  • 详解Python中的join()函数的用法
  • 举例详解Python中的split()函数的使用方法
  • Python os模块中的isfile()和isdir()函数均返回false问题解决方法
  • python中os操作文件及文件路径实例汇总
  • Python中os.path用法分析
  • python多线程编程中的join函数使用心得
  • python多线程编程中的join函数使用心得

相关文章

  • python代码制作configure文件示例
  • python回调函数用法实例分析
  • Python获取DLL和EXE文件版本号的方法
  • Python 调用DLL操作抄表机
  • python使用mysqldb连接数据库操作方法示例详解
  • 通过数据库向Django模型添加字段的示例
  • Python 中 list 的各项操作技巧
  • python3中dict(字典)的使用方法示例
  • 详解Python编程中time模块的使用
  • Python实现的Kmeans++算法实例

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • python实现斐波那契数列的方法示例
    • python实现JAVA源代码从ANSI到UTF-8的批量转换方法
    • python轻松实现代码编码格式转换
    • python编码最佳实践之总结
    • Python利用Nagios增加微信报警通知的功能
    • python实现计算倒数的方法
    • 用实例说明python的*args和**kwargs用法
    • Python的一些用法分享
    • python中安装模块包版本冲突问题的解决
    • python Django批量导入数据

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有