我可以在规则中使用什么公式来实现以下目的:
如果 AA5 和 Y5 上有文本,且为空白,则从 (D5 到 I14) 单元格匹配的单元格 W5 中的数字将以绿色突出显示
类似于:
=(AA5<>"")*(Y5="")
这个问题我已经反复搜索过,但一直没有找到解决方案。我通过 cmd 提示符安装了 discord.py 模块,命令如下:
py -3 -m pip install -U discord.py
再次运行它,会显示依赖项已满足的消息。我在命令提示符中检查了 pip 版本和 python 版本(以查看它们的安装位置)以及 VS Code 终端,它们都确认 Python 版本为 3.13.3。
跑步:
> python
>>> help
>>> modules
输出模块列表,包括和discord
之间的模块。运行输出结果如下:dis
doctest
help> discord
Help on package discord:
NAME
discord
DESCRIPTION
Discord API Wrapper
~~~~~~~~~~~~~~~~~~~
A basic wrapper for the Discord API.
:copyright: (c) 2015-present Rapptz
:license: MIT, see LICENSE for more details.
PACKAGE CONTENTS
(a comprehensive list of all the modules, I've checked)
SUBMODULES
async_
sync
DATA
__annotations__ = {'version_info': <class 'discord.VersionInfo'>}
__copyright__ = 'Copyright 2015-present Rapptz'
__license__ = 'MIT'
__title__ = 'discord'
version_info = VersionInfo(major=2, minor=5, micro=2, releaselevel='fi...
VERSION
2.5.2
AUTHOR
Rapptz
FILE
c:\users\MYUSER\appdata\local\programs\python\python313\lib\site-packages\discord\__init__.py
跑步> pip show discord.py
或> pip3 show discord.py
两者吐出:
Name: discord.py
Version: 2.5.2
Summary: A Python wrapper for the Discord API
Home-page:
Author: Rapptz
Author-email:
License: The MIT License (MIT)
Copyright (c) 2015-present Rapptz
(large portion of legal text ommitted for ease of reading)
Location: C:\Users\MYUSER\AppData\Local\Programs\Python\Python313\Lib\site-packages
Requires: aiohttp, audioop-lts
Required-by:
我确实尝试了所有我认为可行的方法。但无论如何,我创建的任何 .py 文件都会用黄色下划线标出出现错误的discord
行: 。通过 VS Code 运行 python 文件会抛出以下错误:import discord
Import "discord" could not be resolvedPylance(reportMissingImports)
Traceback (most recent call last):
File "c:\Users\MYUSER\OneDrive\Documents\FOLDER_NAME\FOLDER_NAME\FILENAME.py", line 1, in <module>
import discord
ModuleNotFoundError: No module named 'discord'
如果有人能提供任何关于如何解决这个问题的建议,我将不胜感激。提前致谢!
编辑:要添加 IDE 的屏幕截图, 我显然无法嵌入,所以在这里
我连接的公式是:如何使用间接获得相同的信息?
=CONCAT('2101'!C2," - ",'2101'!C3," - ",'2101'!C4," - Admit: ",'2101'!C5)
这是我在不是 CONCAT 时所使用的,但我无法使用 Indirect 合并多个单元格。
=IF(ISBLANK(INDIRECT("'"&B2&"'!"&"C8")),"",INDIRECT("'"&B2&"'!"&"C8"))
1)请在Excel应用程序中运行以下代码。
Sub Macro1()
'Delete all shapes if exists
For i = ActiveSheet.Shapes.Count To 1 Step -1
ActiveSheet.Shapes(i).Delete
Next i
'Add a Rectangle
With ActiveSheet.Shapes.AddShape(Type:=msoShapeRectangle, Left:=20, Top:=20, Width:=200, Height:=120)
.Name = "myRectangle"
End With
'Make some formatting to the myRectangle
With ActiveSheet.Shapes("myRectangle")
.Line.Visible = msoTrue
.Line.ForeColor.RGB = vbBlue
.Line.Weight = 5
.Fill.UserPicture "https://upload.wikimedia.org/wikipedia/en/b/ba/Flag_of_Germany.svg"
End With
End Sub
2)请检查您的Excel 工作表中是否有以下矩形。
3)我正在寻找一个可以给我以下图片的宏。
正如您所理解的,我想在边界和旗帜之间留出一些空白。
DateTimeFormatter
无效Instant
。如何手动格式化上下左右的LocalDateTime.MIN
数值LocalDateTime.MAX
?
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneOffset.UTC).format(Instant.MAX)
首先,这里有一段重现该问题的代码:
import SwiftUI
struct CustomAnimation: ViewModifier {
@State private var isAnimated: Bool = false
func body(content: Content) -> some View {
content
.phaseAnimator([true, false], trigger: self.isAnimated) { view, phase in
view
.scaleEffect(phase ? 1 : 1.2)
}
.onTapGesture {
self.isAnimated.toggle()
}
}
}
#Preview {
@Previewable @State var isPresented: Bool = true
VStack {
Button {
isPresented = true
} label: {
Text("show sheet")
}
}
.sheet(isPresented: $isPresented) {
VStack {
Spacer()
Text("my animated text")
.modifier(CustomAnimation())
}
}
}
问题是,当我将工作表向上拖动时,放置在屏幕底部并带有间隔的动画文本会抖动(并回到原来的位置),此时视图至少已动画过一次。
仅当动画视图粘在屏幕底部(例如,使用间隔物)并且仅在动画之后时,才会出现此问题。
我曾尝试使用仪器挂钩进行调试,但我对此还不熟悉,不太了解如何获取信息。
这个问题不仅在设备上构建,在预览中也会出现。我注意到,如果我将应用置于后台,动画就像没有发生一样,问题也消失了,直到我触发另一个动画。
我正在使用 Next.js App Router API 路由(app/api/notify/route.ts)来检查当前时间(巴西时区)并在达到预定时间时触发通知。
这在本地可以正常工作,但部署到 Vercel 后,我注意到了意外的行为:
❌ 问题:在第一个请求之后,所有后续请求都返回相同的时间戳(从第一次执行开始的冻结时间),即使我在处理程序中使用了 new Date()。
看起来该函数正在被缓存或者环境正在重用相同的上下文。
✅ 预期行为:每次访问路线时,new Date() 都应返回当前时间,以反映请求的实际时刻。
✅ 可重现的步骤:将这个简单的处理程序部署到 Vercel。
向端点发送多个 GET 请求,延迟几秒/几分钟。
您会注意到第一次调用后时间戳和 isoTime 从未改变。
import connectMongo from "@/libs/mongoose";
import Routine from "@/models/Routine";
import User from "@/models/User";
import PushSubscription from "@/models/PushSubscription";
const webPush = require("web-push");
const vapidPublicKey = process.env.NEXT_PUBLIC_WEB_PUSH_PUBLIC_KEY;
const vapidPrivateKey = process.env.WEB_PUSH_PRIVATE_KEY;
if (!vapidPublicKey || !vapidPrivateKey) {
throw new Error("VAPID keys not configured");
}
console.log("VAPID keys configured correctly");
webPush.setVapidDetails("mailto:[email protected]", vapidPublicKey, vapidPrivateKey);
const getBrazilDateTime = () => {
const now = new Date();
const brazilTime = new Date(now.getTime() - 3 * 60 * 60 * 1000); // adjust for Brazil timezone
return brazilTime;
};
const getDayNameInPortuguese = (date) => {
const days = ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado"];
return days[date.getDay()];
};
const getTaskStartTime = (task, currentDay) => {
if (task.dailySchedule instanceof Map && task.dailySchedule.has(currentDay)) {
const daySchedule = task.dailySchedule.get(currentDay);
if (daySchedule && daySchedule.startTime) return daySchedule.startTime;
} else if (task.dailySchedule && typeof task.dailySchedule === "object" && task.dailySchedule[currentDay]?.startTime) {
return task.dailySchedule[currentDay].startTime;
}
if (task.startTime) return task.startTime;
return null;
};
const deduplicateSubscriptions = (subscriptions) => {
const uniqueEndpoints = new Set();
return subscriptions.filter((sub) => {
if (uniqueEndpoints.has(sub.endpoint)) return false;
uniqueEndpoints.add(sub.endpoint);
return true;
});
};
const notifiedTasksCache = new Map();
const isTaskAlreadyNotified = (taskId, userId) => {
const key = `${taskId}-${userId}`;
const lastNotified = notifiedTasksCache.get(key);
if (!lastNotified) return false;
const tenMinutesAgo = Date.now() - 10 * 60 * 1000;
return lastNotified > tenMinutesAgo;
};
const markTaskAsNotified = (taskId, userId) => {
const key = `${taskId}-${userId}`;
notifiedTasksCache.set(key, Date.now());
};
export async function GET(request) {
const headers = new Headers({
"Cache-Control": "no-store, max-age=0, must-revalidate",
"Content-Type": "application/json",
});
const logs = [];
const addLog = (message) => {
console.log(message);
logs.push(`[${new Date().toISOString()}] ${message}`);
};
addLog("🔔 Starting notification check...");
addLog(`🕒 Start timestamp: ${Date.now()}`);
try {
addLog("Connecting to MongoDB...");
await connectMongo();
addLog("MongoDB connection established");
// Update the time on each cycle to ensure the time is current.
const spDate = getBrazilDateTime();
const currentDay = getDayNameInPortuguese(spDate);
const currentTime = spDate.toLocaleTimeString("pt-BR", {
hour: "2-digit",
minute: "2-digit",
hour12: false,
});
addLog(`📅 Brazil date and time: ${spDate.toLocaleString("pt-BR")}`);
addLog(`📅 Day of the week: ${currentDay}`);
addLog(`⏰ Current time: ${currentTime}`);
const users = await User.find({ activeRoutine: { $exists: true, $ne: null } });
addLog(`👥 Found ${users.length} users with active routines`);
if (!users.length) return NextResponse.json({ message: "No users with active routines found." });
const routineIds = users.map((user) => user.activeRoutine).filter(Boolean);
const routines = await Routine.find({ _id: { $in: routineIds } });
const routineMap = new Map();
routines.forEach((routine) => routineMap.set(routine._id.toString(), routine));
let notificationsSent = 0;
let usersNotified = 0;
let duplicatesSkipped = 0;
await Promise.all(
users.map(async (user) => {
const routineId = user.activeRoutine?.toString();
if (!routineId) return;
const routine = routineMap.get(routineId);
if (!routine) return;
const matchingTasks = routine.tasks.filter((task) => {
const taskDays = task.days || [];
const includesDay = taskDays.includes(currentDay);
const taskStartTime = getTaskStartTime(task, currentDay);
return includesDay && taskStartTime === currentTime;
});
if (!matchingTasks.length) return;
for (const matchingTask of matchingTasks) {
if (isTaskAlreadyNotified(matchingTask._id.toString(), user._id.toString())) {
duplicatesSkipped++;
continue;
}
let subscriptions = await PushSubscription.find({ userId: user._id });
if (!subscriptions.length) continue;
subscriptions = deduplicateSubscriptions(subscriptions);
addLog(` 📱 User ${user.email} has ${subscriptions.length} unique devices`);
const payload = JSON.stringify({
title: `🔔 ${matchingTask.name} - Time to start!`,
body: `⏰ ${currentTime} - ${matchingTask.details || "Stay focused on your routine!"}`,
icon: "/icon512_rounded.png",
badge: "/icon192_rounded.png",
tag: `task-${matchingTask._id}`,
data: {
url: `/dashboard/r/${routine._id}`,
taskId: matchingTask._id.toString(),
type: "task-reminder",
timestamp: new Date().toISOString(),
},
actions: [
{ action: "open", title: "📋 View Details" },
{ action: "dismiss", title: "✔️ Got it" },
],
vibrate: [200, 100, 200],
requireInteraction: true,
});
await Promise.all(
subscriptions.map(async (subscription) => {
try {
await webPush.sendNotification(
{
endpoint: subscription.endpoint,
keys: subscription.keys,
},
payload
);
notificationsSent++;
markTaskAsNotified(matchingTask._id.toString(), user._id.toString());
} catch (error) {
if (error.statusCode === 410) {
await PushSubscription.deleteOne({ _id: subscription._id });
}
}
})
);
usersNotified++;
}
})
);
return NextResponse.json(
{
message: `Notifications sent successfully!`,
notificationsSent,
usersNotified,
duplicatesSkipped,
logs,
},
{ headers }
);
} catch (error) {
console.error("Error sending notifications:", error);
return NextResponse.json({ error: "Error processing notifications.", logs }, { status: 500, headers });
}
}
🔍 我尝试过的方法:删除所有外部逻辑 — 上面的最小处理程序仍然会重现该问题。
Vercel 缓存控制标头:似乎不相关。
检查全局或任何静态变量是否保留状态 - 并非如此。
❓ 我的问题:这是 Vercel 函数缓存或 Next.js App Router 中冷启动行为的已知问题吗?
我如何确保对每个请求都评估新的 Date(),而不仅仅是在第一个请求时?
线程 A、B、C 各自执行工作(它们之间无需同步)。当这三个线程都完成后,线程 D 会合并它们的结果。因此,线程 D 的执行依赖于线程 A、B 和 C 的完成。
int a = 0;
int b = 0;
int c = 0;
std::atomic_int D_dependencies{ 3 };
线程A:
a = 1;
D_dependencies.fetch_sub(1, std::memory_order_release);
线程B:
b = 1;
D_dependencies.fetch_sub(1, std::memory_order_release);
线程C:
c = 1;
D_dependencies.fetch_sub(1, std::memory_order_release);
线程D:
if(D_dependencies.load(std::memory_order_acquire) == 0)
{
assert(a + b + c == 3);
}
我的理解是,RMW 操作会fetch_sub
形成一个“释放序列”,因此如果线程 D 中的加载操作从原子变量加载了 0,它应该能够观察到所有写入操作。
我理解得对吗?
我得到了下面的代码片段,由于各种原因我正尝试替换它。
$SubscriptionPIMID = (Get-AzureADMSPrivilegedResource -ProviderId 'AzureResources' -Filter "ExternalId eq '/subscriptions/$subscriptionId'").Id
以上内容需要使用 AzureAdPreview 模块,而我正试图摆脱该模块;其次,当从自动化运行时,它需要执行 Connect-AzureAD,这被证明很难实现自动化,此外我更喜欢使用 Graph。
我尝试了下面的方法。
Connect-MgGraph -Scopes "PrivilegedAccess.Read.AzureResources"
# Set the subscription ID
$subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
# Get the PIM resource for that subscription
$pimResource = Get-MgPrivilegedAccessResource `
-ProviderId "AzureResources" `
-Filter "externalId eq '/subscriptions/$subscriptionId'"
# Output the resource ID
$pimResource.Id
似乎也不起作用,因为
Get-MgPrivilegedAccessResource: The term 'Get-MgPrivilegedAccessResource' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
即使在安装模块并导入图形模块后仍然出现错误。
我正在学习 GraphQL 并尝试使用 Express (v4) 设置 Apollo Server,但是在发出请求时不断收到以下错误/graphql
:
req.body is not set; this probably means you forgot to set up the `json` middleware before the Apollo Server middleware.
这是我的服务器代码:
const express = require("express");
const { ApolloServer } = require('@apollo/server');
const { expressMiddleware } = require('@apollo/server/express4')
const cors = require('cors');
async function startServer() {
const app = express();
const server = new ApolloServer({
typeDefs: `
type Todo {
id: ID!
title: String!
completed: Boolean!
}
type Query {
getTodos: [Todo]
}
`,
resolvers: {
Query: {
getTodos: () => []
}
}
});
await server.start();
app.use('/graphql', cors(), express.json(), expressMiddleware(server));
const PORT = process.env.PORT || 8000;
await new Promise((resolve) => app.listen(PORT, resolve));
console.log(`Server is running on port ${PORT}`);
}
startServer().catch((err) => {
console.error('Error starting the server:', err);
});
我在 expressMiddleware 之前添加了 express.json(),但错误仍然存在。我在使用 Apollo Server 和 Express 4 中间件时是否遗漏了什么?
任何帮助都值得感激!