[RTL8722DM_MINI] SDFS - 目录操作

材料准备

  • AmebaD[AMB23] x 1

  • MicroSD卡 x 1 (SD卡必须 < 32GB,格式设置为 fatfs)

步骤

MicroPython RTL8722 通过从 machine 导入 SDFS 模块来支持 SD 文件系统。该模块是一个简化的文件系统,主要着重于 SD 卡操作,因此它不支持虚拟文件系统。

将以下代码逐行复制粘贴到REPL中来使用。

1from machine import SDFS
2s=SDFS()          # create an instance and mount on file system on SD card
3s.listdir()       # listing the files and folders under current path
4s.mkdir("test")   # create a folder named "test" under current path
5s.chdir("test")   # change directory to test folder
6s.pwd()           # print out present working directory(current path)
7s.chdir("/")      # change directory bach to root directory
8s.rm("test")      # delete the test folder

备注

不需要打开或关闭文件,API 会自动为您完成。