我想知道如何通过消息 ID 获取消息。我试过discord.fetch_message(id)和discord.get_message(id),但都提出:
Command raised an exception: AttributeError: module 'discord' has no attribute 'fetch_message'/'get_message'
Run Code Online (Sandbox Code Playgroud) 我一直在尝试使用 javascript 获取一个 div 元素来跟随我的鼠标,但它总是在左上角出现故障。这是我的代码: HTML:
<html>
<body>
<div id="circle"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
CSS:
body{
margin:0;
padding:0;
overflow:hidden;
background-color:#77dd77;
}
div{
position:absolute;
transform:translate(-50%,-50%);
height:35px;
width:35px;
border-radius:50%;
border:2px solid black;
}
Run Code Online (Sandbox Code Playgroud)
JavaScript:
document.addEventListener('mousemove', function(e) {
let body = document.querySelector('body');
let circle = document.getElementById('circle');
let left = e.offsetX;
let top = e.offsetY;
circle.style.left = left + 'px';
circle.style.top = top + 'px';
});
Run Code Online (Sandbox Code Playgroud)
我仍然很难确定错误是发生在 CSS 还是 JavaScript 中。有人可以帮忙吗?
我想知道如何搜索具有特定名称的行。这是我的带有 json 的 .txt 文件:
{"people": [{"name": "Scott", "website": "stackabuse.com", "from": "Nebraska"}, {"name": "Larry", "website": "google.com", "from": "Michigan"}, {"name": "Tim", "website": "apple.com", "from": "Alabama"}]}
Run Code Online (Sandbox Code Playgroud)
这是我的代码
{"people": [{"name": "Scott", "website": "stackabuse.com", "from": "Nebraska"}, {"name": "Larry", "website": "google.com", "from": "Michigan"}, {"name": "Tim", "website": "apple.com", "from": "Alabama"}]}
Run Code Online (Sandbox Code Playgroud)
这会打印出 Scott,但是有没有办法在 json 文件中搜索名为 Scott 的行?我试过 print(y["people"]["name": "Scott"]) 但这没有用。我希望输出为 {"name": "Scott", "website": "stackabuse.com", "from": "Nebraska"}