[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 會自動為您完成。