سؤال

هناك الكثير من المشاركات المتعلقة بتحليل تويتر JSON، ولكن لا شيء رأيته لحل مشكلتي.

هذا هو رمز giveacodicetagpre.

هذا هو برنامج الاختبار.تتوفر Tweet في الدفق ولتحقق من الغرض، فقد أنقذت تغريدة في ملف وفحصها.هناك جزء تحرير من تغذية تويتر.

هل يمكن لأحد أن يقول لي كيفية تحليل Tweet الذي يتم ترميزه UNI.أول تغريدة في التعليق هي UNI-CONDED والثانية ليست كذلك.هناك خطأ في الأول، أثناء إزالة سلسلة رمز UNI، النجاح التحليل.ما يمكن أن يكون الحل؟

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top