将文件夹中以_r90.jpg为结尾的图片提取出来放入另一个文件夹(完整代码)
时间: 2024-06-06 13:11:11 浏览: 12
import os
import shutil
# 源文件夹路径
src_folder = "/path/to/source/folder"
# 目标文件夹路径
dst_folder = "/path/to/destination/folder"
# 如果目标文件夹不存在,则创建
if not os.path.exists(dst_folder):
os.makedirs(dst_folder)
# 遍历源文件夹中的所有文件和子文件夹
for root, dirs, files in os.walk(src_folder):
# 遍历当前文件夹中的所有文件
for file in files:
# 如果文件以_r90.jpg为结尾,则将其复制到目标文件夹中
if file.endswith("_r90.jpg"):
src_path = os.path.join(root, file)
dst_path = os.path.join(dst_folder, file)
shutil.copy(src_path, dst_path)
print("Copied:", src_path, "->", dst_path)
相关问题
请使用 Arrays 相关的 API,将一个随机字符串中的所有字符升序排列,并倒序打印。
可以使用 Java 中的 Arrays 类的 sort() 和 toString() 方法来实现。
以下是示例代码:
```java
import java.util.Arrays;
public class SortString {
public static void main(String[] args) {
String str = "afweoihfh23r90fksld";
char[] charArray = str.toCharArray(); // 将字符串转为字符数组
Arrays.sort(charArray); // 升序排序
for (int i = charArray.length - 1; i >= 0; i--) { // 倒序打印
System.out.print(charArray[i]);
}
}
}
```
输出结果:
```
wslrrooiihfefkda9320
```
Error[e46]: Undefined external "gpio_config" referred in main ( C:\Users\W1595\Desktop\手动编译\Debug\Obj\main. r90 )
这个错误提示是说在 `main` 函数中引用了未定义的外部函数 `gpio_config`。可能是因为你在 `main` 函数中调用了 `gpio_config` 函数,但是在代码中并没有定义该函数。
要解决这个问题,你需要检查一下代码中是否定义了 `gpio_config` 函数,如果没有,就需要添加相应的函数定义。如果你确定已经定义了该函数,那么可能是因为编译器无法找到函数的定义,你需要检查一下函数定义的位置和声明的位置是否一致。
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)