路径写法
os.path.exists(‘E:/test/file.txt’)
os.path.exists(‘E:\ \test\ \file.txt’)
os.path.exists(r’E:\test\file.txt’)
在python的字符串中\是转义符,如果想让\保持原来的意思,可以在路径前加 r 避免转义。
注:r的全称是raw string,即原始字符串常量,可以让字符保持原来的意思。
url读取本地文件格式:url = ‘file:///E:/Filename/file.txt’
![在这里插入图片描述](https://img-blog.csdnimg.cn/62addf9e76a64ed4b4c5107c982b4bbc.png)