解决:This file isn‘t in your working directory.

1、问题描述

利用 Postman 上传文件时出现问题:This file isn‘t in your working directory. Teammates you share this request with won‘t be able to use this file.

在这里插入图片描述

2、问题解决

原因是上传的文件不在设置的工作区中,只需要重新设置即可。

  • 点击右上角的 Settings

在这里插入图片描述

  • 找到 Location,点击 Choose,重新设置工作区,保证上传的文件在工作区中即可

在这里插入图片描述

### Python OS模块基础用法与功能介绍 #### 获取当前工作目录 为了获取当前工作目录,`os.getcwd()` 函数被提供出来。此函数返回一个字符串表示当前的工作路径[^1]。 ```python import os print(os.getcwd()) ``` #### 创建单层目录 当需要创建一个新的单一层次的目录时,可以调用 `os.mkdir(path)` 方法,在指定位置新建一个文件夹[^5]。 ```python new_directory = "example_folder" os.mkdir(new_directory) print(f"Directory created: {new_directory}") ``` #### 删除空目录 如果要移除某个空的子目录,则可以通过 `os.rmdir(path)` 来实现这一目的。 ```python empty_directory = "./empty_folder" if not os.listdir(empty_directory): # Check if the directory is empty. os.rmdir(empty_directory) print(f"Removed empty directory: {empty_directory}") else: print("The specified directory isn't empty.") ``` #### 列举给定目录下的条目 对于列举特定文件夹内的所有项目(包括文件和其他子文件夹),则应该利用 `os.listdir(path)` 或者更推荐的方式是采用 `os.scandir(path)`,后者不仅效率更高而且能提供更多关于每个项目的元数据信息。 ```python for entry in os.scandir('.'): print(entry.name, 'is a', 'directory' if entry.is_dir() else 'file') ``` #### 修改当前工作目录 改变程序运行期间所处的工作空间可通过 `os.chdir(path)` 实现;这会使得后续相对路径的操作基于新的基底地址进行解析。 ```python target_directory = "/tmp/testdir" os.chdir(target_directory) print(f"Now working in: {os.getcwd()}") ``` #### 文件属性查询 想要知道某文件的具体状态比如大小、最后修改时间戳等细节的话,那么就应当借助于 `os.stat(path)` 接口来完成这项任务。 ```python file_path = './test.txt' info = os.stat(file_path) print('File size:', info.st_size, 'bytes') print('Last modified:', time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(info.st_mtime))) ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值