文件打开:open()函数返回一个文件对象,为文件对象的引用,通过对它 的操作,可对文件进行读写操作

fp=open(file,mode,buffering)

文件路径(file参数):

file为文件路径,文件路径分为绝对路径和相对路径
          绝对路径:从c盘或者d盘(或者其他盘)开始写起

相对路径:根据打开的文件与当前py文件的相对关系来确定路径的写法

路径写法     参考:python文件绝对路径写法(windows)_yangnianjinxin的博客-CSDN博客

一:如果用绝对路径:

二.如果用相对路径:待打开的文件和py文件放在同一个目录中,否则访问不到

fp=open(“a.txt”)

Python 路径问题--No such file or directory相关推荐

  1. python相对路径找不到文件_Python 解决相对路径问题:No such file or directory

    如果你取相对路径不是在主文件里,可能就会有相对路径问题:"No such file or directory". 因为 python 的相对路径,相对的都是主文件. 如下目录结构: ...

  2. python open() 方法 No such file or directory: 应该怎么解决

    python open() 方法 No such file or directory: 应该怎么解决 参考文章: (1)python open() 方法 No such file or directo ...

  3. Linux报错:-bash: 路径xx: No such file or directory解决方法

    为什么80%的码农都做不了架构师?>>>    问题: 出现这个错误-bash: 路径xx: No such file or directory除了cd能用外,所有linux命令都不 ...

  4. python中文件路径如何读取提示nosuch file_Python 解决相对路径问题:No such file or directory...

    如果你取相对路径不是在主文件里,可能就会有相对路径问题:"No such file or directory". 因为 python 的相对路径,相对的都是主文件. 如下目录结构: ...

  5. Python 相对路径问题:“No such file or directory“,原因及解决方法

    如果你取相对路径不是在主文件里,可能就会有相对路径问题:"No such file or directory". 因为 python 的相对路径,相对的都是主文件. 如下目录结构: ...

  6. python读取csv文件路径正确但报错FileNotFoundError: [Errno 2] No such file or directory

    项目场景: python读取csv文件路径正确但报错FileNotFoundError: [Errno 2] No such file or directory 问题描述: #储存调用表格.数据 #调 ...

  7. Python:错误FileNotFoundError: [Errno 2] No such file or directory: 'objects/epsilon.pkl

    目录: 前言 解释 详细解释 前言 看微信推送了一个好玩的应用强化学习dinosrun,但是在运行时,遇到了这个问题,百思不得其解: FileNotFoundError: [Errno 2] No s ...

  8. python Django创建数据库时can't open file 'manage.py': [Errno 2] No such file or directory

    1.在学习Diango新建项目后,进行创建数据库的时候,使用以下命令: python manage.py migrate 2.发现竟然报can't open file 'manage.py': [Er ...

  9. python 文件读取错误之FileNotFoundError: [Errno 2] No such file or directory:,顺便学习斜杠/和反斜杠\的用法

    python 文件读取错误之FileNotFoundError: [Errno 2] No such file or directory:,顺便学习斜杠/和反斜杠\的用法: 最近学习文件读取和中文分词 ...

最新文章

  1. python join 的使用
  2. hbase shell
  3. 网闸与防火墙的区别_网关和网闸、防火墙的区别?
  4. 活动目录系列之一:基本概念
  5. numpy.exp详解
  6. 如何查看python解释器位置_Python:查看解释器的位置
  7. 如何使用XML 配置的方式配置Spring?
  8. 1.5编程基础之循环控制 32 求分数序列和 python
  9. 浙大 PAT 乙级1055
  10. Andrew Ng 的 Machine Learning 课程学习 (week4) Multi-class Classification and Neural Networks
  11. 图像全参考客观评价算法比较
  12. Atitit 资源清理之道与gc之道 gc算法 清理临时表 临时资源 使用的算法类型是 引用计数(reference counting),基于时间过期自动清理资源 1. 3.1. 从各种
  13. oracle 自定义分词器,自定义分词器和自定义词典
  14. D3D9学习笔记之顶点缓存与索引缓存
  15. 推荐一个视频播放器potplayer
  16. 「雅礼集训 2018 Day10」贪玩蓝月
  17. 转载于掘金的vue3学习笔记
  18. loadrunner使用web_add_header添加HTTP信息头(比如Content-Type,token等)和使用
  19. Premiere Pro入门
  20. fname什么意思matlab,matlab中f(:,1)是什么意思 matlab中f(:,:,3)是什么意思?

热门文章

  1. merge 与include
  2. HDU1024 Max Sum Plus Plus【最大子段和+DP】
  3. HDU6109 数据分割【并查集】
  4. 数据科学(data science)概览
  5. matlab 深度学习
  6. 拉普拉斯方程与复微分
  7. 郊寒岛瘦 —— 太平洋的小岛
  8. 代码重构 —— 区分代码和数据
  9. fpga多摩川编码器开源代码_F28379D之CLB解码多摩川编码器1——入手小知识(原创)...
  10. sci translate好用吗_收藏!SCI论文Introduction 和Conclusion的写作建议