Frage

Es gibt viele Beiträge in Bezug auf Parsing Twitter JSON, aber nicht, dass ich mein Problem gelöst habe.

Dies ist Code generasacodicetagpre.

Dies ist das Testprogramm.Tweet kommt in Stream und zum Überprüfen des Zwecks, ich habe einen Tweet in einer Datei gespeichert und überprüft.Es gibt einen bearbeiteten Teil von Twitter-Feed.

Kann mir jemand sagen, wie man den Tweet analysiert, der uni-codiert ist.Der erste Tweet im Kommentar ist uni-codiert und der zweite ist nicht.Es ist zunächst Fehler, während Sie die Uni-Code-Zeichenfolge entfernen, das Parsing ist erfolgreich.Was kann die Lösung sein?

War es hilfreich?

Lösung

I think your code works, the reason for the error is probably because of a UnicodeEncodeError which happens when you try to print the unicode value to the terminal. I'm guessing you are calling the script in a non-unicode aware terminal. If instead you printed the repr of the unicode value, or (wrote it to an output file) it would probably work:

print "text : ", repr(singleTweetJson[index])

Also its generally bad practice to hide specific exceptions/error messages with generic catch-all exceptions/error messages.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top