Closed Mepuru closed 11 months ago
可以告诉我下面这段代码的输出吗
import asyncio
import json
from mcstatus import JavaServer
IP = 'hypixel.net' # 换成你的服务器 IP
async def main():
svr = await JavaServer.async_lookup(IP)
res = await svr.async_status()
json_str = json.dumps(res.raw, ensure_ascii=False, indent=2)
print(json_str)
asyncio.run(main())
Tip: 虚拟环境运行 python
,粘贴后回车
所以结果是 怎么解决的啊
我也有类似的报错
ERROR nonebot_plugin_picmcstat >> 获取服务器状态/画服务器状态图出错 Traceback (most recent call last):
File "/bot/atri/main.py", line 9, in
File "/bot/atri/ATRI/init.py", line 36, in run nonebot.run(log_level=log_level) │ │ └ 'warning' │ └ <function run at 0x7f9e5af8f760> └ <module 'nonebot' from '/root/.cache/pypoetry/virtualenvs/atri-TKW06R_y-py3.10/lib/python3.10/site-packages/nonebot/init....
File "/root/.cache/pypoetry/virtualenvs/atri-TKW06R_y-py3.10/lib/python3.10/site-packages/nonebot/init.py", line 331, in run
get_driver().run(*args, **kwargs)
│ │ └ {'log_level': 'warning'}
│ └ ()
└ <function get_driver at 0x7f9e5af8f5b0>
File "/root/.cache/pypoetry/virtualenvs/atri-TKW06R_y-py3.10/lib/python3.10/site-packages/nonebot/drivers/fastapi.py", line 201, in run
uvicorn.run(
│ └ <function run at 0x7f9e5a184670>
└ <module 'uvicorn' from '/root/.cache/pypoetry/virtualenvs/atri-TKW06R_y-py3.10/lib/python3.10/site-packages/uvicorn/init....
File "/root/.cache/pypoetry/virtualenvs/atri-TKW06R_y-py3.10/lib/python3.10/site-packages/uvicorn/main.py", line 578, in run
server.run()
│ └ <function Server.run at 0x7f9e5a184820>
└ <uvicorn.server.Server object at 0x7f9e35181ff0>
File "/root/.cache/pypoetry/virtualenvs/atri-TKW06R_y-py3.10/lib/python3.10/site-packages/uvicorn/server.py", line 61, in run
return asyncio.run(self.serve(sockets=sockets))
│ │ │ │ └ None
│ │ │ └ <function Server.serve at 0x7f9e5a1848b0>
│ │ └ <uvicorn.server.Server object at 0x7f9e35181ff0>
│ └ <function run at 0x7f9e5c118550>
└ <module 'asyncio' from '/usr/lib/python3.10/asyncio/init.py'>
File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
│ │ └ <coroutine object Server.serve at 0x7f9e382e9ee0>
│ └ <method 'run_until_complete' of 'uvloop.loop.Loop' objects>
└
File "/bot/atri/ATRI/patch.py", line 41, in simple_run await handler( └ Dependent(call=shortcut_handler)
File "/root/.cache/pypoetry/virtualenvs/atri-TKW06R_y-py3.10/lib/python3.10/site-packages/nonebot/dependencies/init.py", line 113, in call
return await cast(Callable[..., Awaitable[R]], self.call)(**values)
│ │ │ │ │ │ └ {'matcher': Matcher(type='message', module=nonebot_plugin_picmcstat.main, lineno=59)}
│ │ │ │ │ └ <function get_shortcut_handler.
File "/bot/atri/ATRI/patch.py", line 41, in simple_run await handler( └ Dependent(call=shortcut_handler)
File "/root/.cache/pypoetry/virtualenvs/atri-TKW06R_y-py3.10/lib/python3.10/site-packages/nonebot/dependencies/init.py", line 113, in call
return await cast(Callable[..., Awaitable[R]], self.call)(**values)
│ │ │ │ │ │ └ {'matcher': Matcher(type='message', module=nonebot_plugin_picmcstat.main, lineno=59)}
│ │ │ │ │ └ <function get_shortcut_handler.
File "/root/.cache/pypoetry/virtualenvs/atri-TKW06R_y-py3.10/lib/python3.10/site-packages/nonebot_plugin_picmcstat/draw.py", line 329, in draw return draw_bedrock(status, original_ip) │ │ └ 'qymc.sytes.net:19132' │ └ BedrockStatusResponse(players=BedrockStatusPlayers(online=0, max=202312), version=BedrockStatusVersion(name='1.20.41', protoc... └ <function draw_bedrock at 0x7f9e14337be0> File "/root/.cache/pypoetry/virtualenvs/atri-TKW06R_y-py3.10/lib/python3.10/site-packages/nonebot_plugin_picmcstat/draw.py", line 276, in draw_bedrock motd = strip_lines(res.motd) │ │ └ Motd(parsed=['齐悦幻想'], raw='齐悦幻想', bedrock=True) │ └ BedrockStatusResponse(players=BedrockStatusPlayers(online=0, max=202312), version=BedrockStatusVersion(name='1.20.41', protoc... └ <function strip_lines at 0x7f9e14337400> File "/root/.cache/pypoetry/virtualenvs/atri-TKW06R_y-py3.10/lib/python3.10/site-packages/nonebot_plugin_picmcstat/util.py", line 44, in strip_lines txt = "\n".join([x.strip() for x in txt.splitlines()]) └ Motd(parsed=['齐悦幻想'], raw='齐悦幻想', bedrock=True)
AttributeError: 'Motd' object has no attribute 'splitlines'