贴个代码方便以后用:
if __name__ == '__main__': client = Pybilidanmu() tasks = [ client.enter_room(), ] loop = asyncio.get_event_loop() try: loop.run_until_complete(asyncio.wait(tasks)) except KeyboardInterrupt: for tasks in asyncio.Task.all_tasks(): task.cancel() loop.run_forever() loop.close()