【问题标题】:Syntax error in Python 3, telethon library [closed]Python 3 中的语法错误,telethon 库 [关闭]
【发布时间】:2022-11-30 04:17:33
【问题描述】:

我最近正在开发一个电视节目应用程序并发现了这个奇怪的错误:

    exec(open(mainpyfile).read(),  __main__.__dict__)

  File "<string>", line 19

    dialogs = client.get_dialogs()

    ^

SyntaxError: invalid syntax

代码本身: `

client.connect()

if not client.is_user_authorized():

    client.send_code_request(phone)

    client.sign_in(phone, input('code: ')

    dialogs = client.get_dialogs()

for dialog in dialogs:

    print(f"{dialog.name} (id={dialog.id})" )

    conts.append(f"{dialog.id}")

print(conts)

for i in conts:

    client.send_message(int(i), 's')`

或者它是 pastebin 版本:https://pastebin.com/QRijCF8E

应用程序必须向所有活动聊天发送一些消息

【问题讨论】:

  • 您在上一行有未闭合的括号

标签: python telethon


【解决方案1】:

问题是您在 client.sign_in(phone, input('code: ') 处缺少右括号 ())。

    # Code snippet with correction
    client.sign_in(phone, input('code: '))
    dialogs = client.get_dialogs()

【讨论】:

  • 请不要对打字错误的问题留下完整的答案。投票关闭并帮助发表评论。
猜你喜欢
  • 2017-11-21
  • 2018-09-23
  • 2021-09-14
  • 2012-12-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-09-27
相关资源
最近更新 更多