我正在阅读以下格式的数据:
{ok,Volts} = file:open("voltage1.dat",read).
在“voltage.dat”文件中,有一个值被转换为字符串
" 9.9944639227844667e-001\n". 这应该分配给Volts变量。
为了稍后使用 string_to_float 函数,我需要去掉空格并删除 \n 分隔符。
我探索了使用string:strip,string:substr和re:replace库函数。
当我尝试其中的每一个时,我使用变量 Volts 作为输入字符串,例如:
string:substr(Volts,3,18).
这不起作用。我认为这是因为我输入Volts变量的方式。
任何人都可以让我正确吗?