I use this code to create a json data package. The datapackage gets a newline character appended: 'fields': {'time': '31.495\n'} How do I get rid of this \n?
import subprocess, signal, os, pylibmc, time, datetime
# Send network ping delay time to influxdb
cmd = "ping -c 1 1.0.0.1 | tail -1| awk '{print $4}' | cut -d '/' -f 2" # pylint: disable=line-too-long
data=subprocess.check_output(cmd, shell=True).decode("utf-8")
print(data)
stamp=time.ctime()
print(id)
print("[%s] Time: %s" % (stamp, data))
print(data)
#Create the JSON data structure
data = [
{
"measurement": "ping_delay",
"tags": {
"location": location,
},
"time": stamp,
"fields": {
"delay" : data,
}
}
]
# Send the JSON data to InfluxDB
print(data)