向文件写入字符串数据。
write(data)
示例
写入交易记录
javascript function main() { let file = os.open("trades.log", "a") let timestamp = new Date().toISOString() let tradeInfo = `${timestamp},BUY,50000,1\n` let bytes = file.write(tradeInfo) Log("Trade record written, bytes:", bytes) file.close() }
返回值
number
返回实际写入的字节数。
参数
data
string
要写入的字符串数据。
参考
close puts printf flush tell seek eof read write getline toString
close
puts
printf
flush
tell
seek
eof
read
write
getline
toString
备注
将字符串数据写入文件的当前位置。