问题描述
我正在编写一个程序,该程序使用sign_up method提供的telethon library创建电报帐户。当我输入程序发送到手机的代码时,尽管代码有效,它仍返回PhoneCodeInvalidError。
from telethon import TelegramClient
async def main():
phone = '+390000000000'
await client.connect()
await client.send_code_request(phone)
code = input('enter code: ')
await client.sign_up(phone=phone,code=code,first_name="Anna")
if __name__ == '__main__':
client = TelegramClient('helohelohelo',12345,abcdefghi)
client.loop.run_until_complete(main())
我一直在到处寻找解决方案,很少有人谈论这个问题,而且我阅读的几乎所有内容都没有清晰的分辨率说明。
解决方法
通过电报发送的任何代码都会立即失效。尝试在代码的每个数字之间放置空格。