小编Ric*_*ard的帖子

我需要导入一个txt文件作为特定函数的列表

我正在尝试保存并加载传感器的校准数据.我能够读取校准数据并将其保存到文本文件中.查看文本文件时,在一组方括号中有22个由逗号分隔的数字.

我需要以set_calibration函数读取它的方式导入该文本文件.

这是设定校准功能.

def set_calibration(self, data):
    """Set the sensor's calibration data using a list of 22 bytes that
    represent the sensor offsets and calibration data.  This data should be
    a value that was previously retrieved with get_calibration (and then
    perhaps persisted to disk or other location until needed again).
    """
    # Check that 22 bytes were passed in with calibration data.
    if data is None or len(data) != 22:
        raise ValueError('Expected a list of 22 bytes for calibration data.')
    # …
Run Code Online (Sandbox Code Playgroud)

python raspberry-pi

0
推荐指数
1
解决办法
84
查看次数

标签 统计

python ×1

raspberry-pi ×1