SD卡#
加载文件()#
The loadfile(filename, buffer, len)
method loads the named file. If the optional bytearray is None, then an empty file is created.
参数 |
描述 |
---|---|
文件名 |
要读取的文件的名称。 |
缓冲 |
指向内存中存储文件数据的位置的指针。 |
len |
缓冲区的长度(以字节为单位)。 |
**返回:**包含文件数据的字节数组。
是否插入()#
The is_inserted()
method returns the status of the SD Card.
Returns: True
if an SD card is inserted into the brain. False
if it is not.
尺寸()#
The size(filename)
method returns the size in bytes of the named file.
参数 |
描述 |
---|---|
文件名 |
要检查的文件的名称。 |
**返回:**文件的大小(以字节为单位)。
保存文件()#
The savefile(filename, buffer, len)
method saves a bytearray into a named file. If the optional bytearray is None, then an empty file is created.
参数 |
描述 |
---|---|
文件名 |
要写入的文件的名称。 |
缓冲 |
指向内存中存储文件数据的位置的指针。 |
len |
缓冲区的长度(以字节为单位)。 |
**返回:**写入的字节数。
// Write the bytearray into a file.
Brain.SDcard.savefile('MyTextFile.txt', bytearray("Hello "))
追加文件()#
The appendfile(filename, buffer, len)
method appends a bytearray into a named file. Append is used to add more data to an existing file.
参数 |
描述 |
---|---|
文件名 |
要写入的文件的名称。 |
缓冲 |
指向内存中存储文件数据的位置的指针。 |
len |
缓冲区的长度(以字节为单位)。 |
**返回:**写入的字节数。
# Append the bytearray into a file.
Brain.sdcard.appendfile('MyTextFile.txt', bytearray("World "))
尺寸()#
The size(filename)
method returns the size in bytes of the named file.
参数 |
描述 |
---|---|
文件名 |
要检查的文件的名称。 |
**返回:**文件的大小(以字节为单位)。
存在()#
The exists(filename)
method checks to see if the named file exists on the sd card.
参数 |
描述 |
---|---|
文件名 |
要检查的文件的名称。 |
Returns: true
if file exists. false
if it does not exist.