[Python-hu] timestamp beillesztése
Szekeres István
szekeres at iii.hu
2017. Jan. 30., H, 15:42:05 EST
out.write('*%s* %f\t%s\t%s\t%f\t%f\t%f\n' % (*timestamp, *lux, rgb, acc,
heading, temp, press))
2017-01-30 20:28 GMT+00:00 Kerti Balázs Gábor via Python-hu <
python-hu at python.org>:
> _______________________________________________
> Python-hu mailing list
> Python-hu at python.org
> https://mail.python.org/mailman/listinfo/python-hu
>
>
> ---------- Forwarded message ----------
> From: "Kerti Balázs Gábor" <kerti.balazs at mkk.szie.hu>
> To: python-hu at python.org
> Cc:
> Date: Mon, 30 Jan 2017 21:28:19 +0100
> Subject: timestamp beillesztése
> Kedves Lista tagok!
>
> Van egy Enviro pHAT amit egy Raspberry Pi zero-hoz csatoltam.
>
> Az
>
> https://learn.pimoroni.com/tutorial/sandyj/getting-started-
> with-enviro-phat
>
> oldal szerint be is üzemeltem, és kezdésnek egy enviro_logger.py fájlt
> futtatok a
>
> python enviro_logger.py
>
> utasítással.
>
> A fájl tartalmaz:
>
> import time
> from envirophat import light, motion, weather, leds
>
> out = open('enviro.log', 'w')
> out.write('light\trgb\tmotion\theading\ttemp\tpress\n')
>
> try:
> while True:
> lux = light.light()
> leds.on()
> rgb = str(light.rgb())[1:-1].replace(' ', '')
> leds.off()
> acc = str(motion.accelerometer())[1:-1].replace(' ', '')
> heading = motion.heading()
> temp = weather.temperature()
> press = weather.pressure()
> out.write('%f\t%s\t%s\t%f\t%f\t%f\n' % (lux, rgb, acc, heading,
> temp, press))
> time.sleep(60)
>
> except KeyboardInterrupt:
> leds.off()
> out.close()
>
> Az enviro.log fájl kimenetének első két sora:
> light rgb motion heading
> temp press
> 5.000000 153,102,51 -0.11981201171875,0.18646240234375,1.04229736328125
> 241.800000 -3.760940 101324.863498
>
> Szeretném betenni az ún. "timestamp"-et a kimenet első érékének.
>
> import datetime
>
> timestamp = datetime.datetime.now().isoformat()
>
> paranccsal tudok, de elakadtam ott, hogy az
>
> out.write('%f\t%s\t%s\t%f\t%f\t%f\n' % (lux, rgb, acc, heading, temp,
> press))
>
> sorba, ezt hogy írjam be, hogy ez legyen a kimenet, bár a másodperchez
> (51.041608 ) nem ragaszkodok.
>
> time light
> rgb motion heading temp press
> 2017-01-30 20:22:51.041608 5.000000 153,102,51
> -0.11981201171875,0.18646240234375,1.04229736328125 241.800000 -3.760940
> 101324.863498
>
> Tudna valaki segíteni?
>
> Előre is köszönöm!
> Balázs
>
>
--------- következő rész ---------
Egy csatolt HTML állomány át lett konvertálva...
URL: <http://mail.python.org/pipermail/python-hu/attachments/20170130/4ee84f95/attachment.html>
További információk a(z) Python-hu levelezőlistáról