[英]Call to a function using python gives not defined error
我需要為PORTFOLIO分配一個NOTE。 我已經用Python編寫了代碼以登錄到LendingClub,並且工作正常(我能夠獲得余額)。 當我調用assign_to_portfolio()函數時,出現錯誤“ NameError:未定義名稱'assign_to_portfolio'”
但是我已經運行了“ import lendingclub”命令,assign_to_portfolio()是init .py的一部分,如https://github.com/jgillick/LendingClub/blob/master/lendingclub/ init .py所示 。 我究竟做錯了什么?
lc_InvestorId = "xxxxx"
lc_apikey = "xxxxxxxxxxxxxxxx"
url = "https://api.lendingclub.com/api/investor/v1/accounts/" + lc_InvestorId + "/availablecash"
import requests
import argparse
import sys
import glob
from lendingclub import LendingClub
import lendingclub
payload = ""
headers = {
'ContentType': "application/json",
'Accept': "application/json",
'Authorization': lc_apikey,
'X-LC-Application-Key': "null"
}
response = requests.request("GET", url, data=payload, headers=headers)
print(response.text)
assign_to_portfolio()
LendingClub
實例上調用assign_to_portfolio()
根據我的理解,閱讀LendignClub類的自述文件和文檔字符串:
您可以通過將它們作為參數來“連接”到您的帳戶的電子郵件和密碼LendingClub
,然后調用.authenticate()
或呼叫在控制台將它們插入.authenticate()
上的默認實例LendingClub
。 然后,您可以使用.authenticate()
ed實例執行操作。
為了使所有功能都能按預期工作,建議您按照自述文件中的示例進行操作(它們是否提供模擬帳戶?),然后添加您想要的內容。
閱讀自述文件后,我必須說,我對問題的理解較少,您確定您沒有使事情變得過於復雜嗎? (就像使用簡單的python包將使用API模仿瀏覽器進行混合一樣)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.