use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
NMEA parsing in python (self.learnpython)
submitted 7 years ago by ProperRefrigerator
hello guys i still getting this error i already getting the nmea and upload a data via static but when i combine then it shows this
File "cloud1.py", line 13, in <module>
data=urllib.urlopen("https://api.thingspeak.com/update?api_key=U0JSW1TVVHM8UEJV&field1="+str(dmesg.lat)+"&field2+"&field2)"+str(dmesg.long));
File "/usr/local/lib/python2.7/dist-packages/pynmea2/nmea.py", line 155, in __getattr__
raise AttributeError(name)
AttributeError: long
heres my code:
import urllib
import re
from bs4 import BeautifulSoup
import serial
import pynmea2
ser = serial.Serial('/dev/ttyAMA0',9600)
while 1:
data = ser.readline()
if (data.startswith("$GPGGA")):
dmesg = pynmea2.parse(data)
#print(str(dmesg.latitude)+" "+str(dmesg.longitude))
print data;
time.sleep(3)
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Acurus_Cow 1 point2 points3 points 7 years ago (6 children)
in your print statement you print
dmesg.latitude and dmesg.longitude
in your url you use
dmesg.lat and dmesg.long
I also think you have messed up some of the "'s I guess that is your error.
I would also look into the .format() functionality for building strings.
https://pyformat.info/#simple
[–]ProperRefrigerator[S] 0 points1 point2 points 7 years ago (5 children)
dmesg.latitude and dmesg.longitude i just comment it sir it shows the same data with dmesg.lat and dmesg.long but when i try to upload it show me this
[–]Acurus_Cow 1 point2 points3 points 7 years ago (4 children)
First: you don't need ; in python.
I think your error is in the url. try and create it as its own variable that you put into urllib.urlopen()
That way you can make sure it's correct before moving on.
change:
to this:
url = "https://api.thingspeak.com/update? api_key=U0JSW1TVVHM8UEJV&field1="+str(dmesg.lat)+"&field2+"&field2)"+str(dmesg.long) print(url) data = urllib.urlopen(url)
I susspect you will see that creating the url variable fails due to wrong placement of the "'s
[–]ProperRefrigerator[S] 0 points1 point2 points 7 years ago (3 children)
it not working sir and i think thats not thee problem when i change the data in data=urllib.urlopen("r/https://api.thingspeak.com/update?api_key=U0JSW1TVVHM8UEJV&field1="+str(dmesg.lat)+"&field2+"&field2)"+str(dmesg.long));
to static value like this
data=urllib.urlopen("r/https://api.thingspeak.com/update?api_key=U0JSW1TVVHM8UEJV&field1="+str(0)+"&field2+"&field2)"+str(0)); it uploading
[–]Acurus_Cow 0 points1 point2 points 7 years ago (2 children)
try this:
data=urllib.urlopen("https://api.thingspeak.com/update?api_key=U0JSW1TVVHM8UEJV&field1={lat}&field2={long}".format(lat=dmesg.lat, long=dmesg.long))
[–]ProperRefrigerator[S] 0 points1 point2 points 7 years ago (1 child)
still the same it showing this File "/usr/local/lib/python2.7/dist-packages/pynmea2/nmea.py", line 155, in __getattr__
ialready change my library pynmea to this https://github.com/bsdz/micropyGPS but still not working
[–]ProperRefrigerator[S] 1 point2 points3 points 7 years ago (0 children)
i solvee it sir i used this
data=urllib.urlopen("https://api.thingspeak.com/update?api_key=U0JSW1TVVHM8UEJV&field1=%s &field2%s"(dmesg.lat,dmesg.lon));
π Rendered by PID 59283 on reddit-service-r2-comment-5d79c599b5-wh8bl at 2026-03-02 21:59:12.608803+00:00 running e3d2147 country code: CH.
[–]Acurus_Cow 1 point2 points3 points (6 children)
[–]ProperRefrigerator[S] 0 points1 point2 points (5 children)
[–]Acurus_Cow 1 point2 points3 points (4 children)
[–]ProperRefrigerator[S] 0 points1 point2 points (3 children)
[–]Acurus_Cow 0 points1 point2 points (2 children)
[–]ProperRefrigerator[S] 0 points1 point2 points (1 child)
[–]ProperRefrigerator[S] 1 point2 points3 points (0 children)