小编squ*_*idg的帖子

Python3 SQLAlchemy 删除重复项

我正在使用 SQLAlchemy 来管理数据库,并尝试删除所有包含重复项的行。该表有一个 id(主键)和域名。

示例:
ID| 域
1 | example-1.com
2 | example-2.com
3 | example-1.com

在本例中,我想删除 example-1.com 的 1 个实例。有时我需要删除超过 1 个域,但一般来说,数据库不应多次拥有一个域,如果有,则只应保留第一行,而应删除其他行。

python sqlalchemy

6
推荐指数
1
解决办法
3687
查看次数

python-telegram-bot - 发送消息

我正在尝试使用 Python-Telegram-Bot 发送消息而不等待用户响应,但无法让它工作,并且没有收到任何错误。

Code:
def echo(context):
    context.bot.send_message(chat_id=-516017547, text='test') 
    #chat_id is the group id I found by going to:
    #https://api.telegram.org/bot<MY_API>/getUpdates

def main():
    updater = Updater(API)
    dp = updater.dispatcher

    echo_handler = MessageHandler(Filters.text & (~Filters.command), echo)
    dp.add_handler(echo_handler)

    updater.start_polling()
    updater.idle()

main()
Run Code Online (Sandbox Code Playgroud)

python-3.x python-telegram-bot

3
推荐指数
1
解决办法
9029
查看次数