Python中的DeprecationWarning是什么?

2024-06-08 06:10:49 发布

您现在位置:Python中文网/ 问答频道 /正文

尝试使用Flask开发Python应用程序,使用OData服务连接到saphana。当尝试打开url时,整个应用程序崩溃,我得到一个DeprecationWarning。弃用警告的目的是什么?你知道吗

from flask import Flask, render_template, request
from pyslet.odata2.client import Client
from pyslet.http.auth import BasicCredentials
from pyslet.http.client import Client as http
from pyslet.http.client import ClientRequest

app = Flask(__name__)

@app.route('/')
def test():
    return('test')

@app.route('/odata')
def hello():
    table = testClient()
    return render_template('odata.html', table=table)

def testClient():
    c = MyAuthenticatedClient('link to xso data')
    table = c.feeds['MarketShareFSet'].OpenCollection()
    tablenames = []
    for t in table.iteritems():
        c1 = p['ID'].value
        c2 = p['Country'].value
        c3 = p['Hub'].value
        c4 = p['Division'].value
        tablenames.append((c1, c2,c3,c4))

    return tablenames
127.0.0.1 - - [13/Mar/2019 13:59:40] "GET / HTTP/1.1" 200 -
main.py:23: DeprecationWarning: EntitySet.OpenCollection is deprecated, use open instead
  table = c.feeds['MarketShareFSet'].OpenCollection()

Tags: fromimportclientapp应用程序httpflaskreturn
1条回答
网友
1楼 · 发布于 2024-06-08 06:10:49

来自维基百科:

In several fields, deprecation is the discouragement of use of some terminology, feature, design, or practice, typically because it has been superseded or is no longer considered efficient or safe, without completely removing it or prohibiting its use.

它警告您,OpenCollection()方法现在不是最好的使用方法(无论出于什么原因),而最佳实践是使用open()方法。你知道吗

通常在软件中,东西会贬值,然后,以后,就不再支持或从更高版本的版本中删除。你知道吗

相关问题 更多 >

    热门问题