亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

發送請求失?。褐挥?unicode 對象是可轉義的。沒有類型 <class 'NoneType'>

發送請求失?。褐挥?unicode 對象是可轉義的。沒有類型 <class 'NoneType'>

喵喔喔 2022-06-02 12:08:02
我按照本教程將我的 django 應用程序部署到 RHEL 8 服務器: https ://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on- centos-7內部 django 網絡服務器與python manage.py runserver 0:8000無論如何,槍手沒有。500 調試錯誤中的內部服務器錯誤,否則會出現以下問題:TweepError at /Failed to send request: Only unicode objects are escapable. Got None of type <class 'NoneType'>.Request Method:     GETRequest URL:    http://ip/Django Version:     2.2.5Exception Type:     TweepErrorException Value:    Failed to send request: Only unicode objects are escapable. Got None of type <class 'NoneType'>.Exception Location:     /home/ec2-user/django_sentiment/env/lib/python3.7/site-packages/oauthlib/oauth1/rfc5849/utils.py in escape, line 57Python Executable:  /home/ec2-user/django_sentiment/env/bin/pythonPython Version:     3.7.4Python Path:    ['/home/ec2-user/django_sentiment', '/home/ec2-user/django_sentiment/env/bin', '/home/ec2-user/.pyenv/versions/3.7.4/lib/python37.zip', '/home/ec2-user/.pyenv/versions/3.7.4/lib/python3.7', '/home/ec2-user/.pyenv/versions/3.7.4/lib/python3.7/lib-dynload', '/home/ec2-user/django_sentiment/env/lib/python3.7/site-packages']Server time:    Thu, 19 Sep 2019 23:30:33 +0000</i>TRACEBACKEnvironment:Request Method: GETRequest URL: http://ip/Django Version: 2.2.5Python Version: 3.7.4Installed Applications:['twitter.apps.TwitterConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles']Installed Middleware:['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware']
查看完整描述

3 回答

?
慕的地8271018

TA貢獻1796條經驗 獲得超4個贊

看起來您正在使用 tweepy 從推文中獲取情緒。您需要 Twitter API 憑據才能執行此操作。這個錯誤的意思是你的一些 API 憑證是None. 您應該確保正確設置了存儲 API 憑據的任何環境變量。應該有4個:

  • 消費者 API 密鑰

  • 消費者 API 秘密

  • 訪問令牌

  • 訪問令牌秘密

您可以使用一個小的 python 腳本來測試 tweepy API 是否正常工作:

import os


import tweepy


c_key = os.environ.get('tw_c_key')

c_sec = os.environ.get('tw_c_sec')

atk = os.environ.get('tw_ac_tok')

ats = os.environ.get('tw_ac_sec')


auth = tweepy.OAuthHandler(c_key, c_sec)

auth.set_access_token(atk, ats)


api = tweepy.API(auth)


results = api.search(q='cheese', count=100)


print(results[1].text)

您可能需要更改環境變量名稱以匹配您所擁有的。


查看完整回答
反對 回復 2022-06-02
?
慕虎7371278

TA貢獻1802條經驗 獲得超4個贊

可能是在獲取環境變量期間,None正在返回類型。
使用以下語法在終端(在項目目錄中)設置您的特定環境變量:

export 'KEY'='KEY_VALUE'


查看完整回答
反對 回復 2022-06-02
?
慕尼黑的夜晚無繁華

TA貢獻1864條經驗 獲得超6個贊

當我收到 Tweepy 的錯誤時,我所做的和工作出色的不是:

open(r"file")

我會寫它而不是打開文件,所以不要打開文件,而是將文件中的內容粘貼為字符串:

"asfd5asdf56asdfa56"

希望它對你有幫助,也對你有用。


查看完整回答
反對 回復 2022-06-02
  • 3 回答
  • 0 關注
  • 158 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號