阿赵UE引擎C++编程学习笔记——时间日期相关

  大家好,我是阿赵。
  这次来看看UE引擎使用C++来控制时间和日期相关的方法。

一、获取日期时间

  时间的获取基本上都是用FDateTime
获取当前的:

FDateTime::Now()

显示日期时间举例:

FDateTime dt = FDateTime::Now();
UE_LOG(LogTemp, Display, TEXT("当前时间:%d年%d月%d日%d时%d分%d秒"), dt.GetYear(), dt.GetMonth(), dt.GetDay(), dt.GetHour(), dt.GetMinute(), dt.GetSecond());

二、获取时间戳

  时间戳是指从1970年1月1日凌晨开始算起到现在的秒数,或者毫秒数。
获取时间戳的方法有几种:

1、std::chrono

#include <chrono>
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();

  这个方法需要include ,但有个问题是会有时区问题,获取完之后还需要自己加上系统所在地的时区。

2、FDateTime时间相减

毫秒

(FDateTime::Now() - FDateTime(1970, 1, 1)).GetTotalMilliseconds();

(FDateTime::Now() - FDateTime(1970, 1, 1)).GetTotalSeconds();

这个方法暂时没发现没什么问题

3、ToUnixTimestamp

FDateTime::Now().ToUnixTimestamp();

这个方法只能获得秒级时间戳

三、时间戳转日期时间

从时间戳转FDateTime:

FDateTime dt = FDateTime::FromUnixTimestamp(int32 t);

注意这个方法接受的时间戳是秒级的。

四、计时器

自带的计时器方法使用SetTimer方法来实现
举例:
倒计时5秒:

GetWorldTimerManager().SetTimer(timerHandle, this, &OnTime, 5);

其中OnTime是回调函数,5是指5秒钟后执行
每2秒钟执行一次,首次执行延时5秒:

GetWorldTimerManager().SetTimer(timerHandle, this, &OnTime,2,true,5);

其中OnTime是回调函数,2是执行的频率,true是是否循环,5是首次执行时的延时

五、自定义时间管理类

  我一直喜欢自己定义时间管理的工具,所以写了这么一个工具类,里面包含了获取时间、时间戳、时间戳转时间、使用倒计时、Deadline、每隔多少频率执行等等方法,不是使用SetTimer来实现,而是自己控制Tick和当前时间的关系来做时间控制:
AzhaoTimeMgr.h

#pragma once#include "CoreMinimal.h"
#include "TimeCtrlData.h"
#include "TimeEventType.h"
/*** */class UECPPTEST_API AzhaoTimeMgr 
{
public://DECLARE_DELEGATE_OneParam(TimeCompleteHandler, int);//DECLARE_DELEGATE_TwoParams(TimeEveryHandler, int, int);static void Tick();	/// <summary>/// 获取AzhaoTimeMgr单例/// </summary>/// <returns></returns>static AzhaoTimeMgr* GetInstance();/// <summary>/// 获取当前时间/// </summary>/// <returns></returns>static FDateTime GetDateTime();/// <summary>/// 通过秒级时间戳获得当前时间/// </summary>/// <param name="t"></param>/// <returns></returns>static FDateTime GetDateTimeFromTimestamp(int64 t);/// <summary>/// 通过毫秒级时间戳获得当前时间/// </summary>/// <param name="t"></param>/// <returns></returns>static FDateTime GetDateTimeFromTimestampMs(int64 t);/// <summary>/// 获取系统毫秒级时间戳/// </summary>/// <returns></returns>static int64 GetSystemTime();/// <summary>/// 获取游戏秒级时间戳/// </summary>/// <returns></returns>static int64 GetNowTime();/// <summary>/// 获取游戏毫秒级时间戳/// </summary>/// <returns></returns>static int64 GetNowTimeMs();/// <summary>/// 获取当前帧的事件,单位毫秒/// </summary>/// <returns></returns>static int64 GetFrameTime();/// <summary>/// 设置服务器时间戳/// </summary>/// <param name="t">服务器时间戳,单位毫秒</param>static void SetServerTime(int64 t);/// <summary>/// 设置秒级deadLine/// </summary>/// <param name="deadLine">秒级deadLine</param>/// <param name="completeHandler">完成回调</param>/// <param name="everyHandler">每秒回调</param>/// <returns></returns>static int64 SetDeadLine(int64 deadLine, void (*completeHandler)(int64), void (*everyHandler)(int64,int64) = nullptr);/// <summary>/// 设置毫秒级deadLine/// </summary>/// <param name="deadLine">毫秒级deadLine</param>/// <param name="completeHandler">完成回调</param>/// <param name="everyHandler">每秒回调</param>/// <returns></returns>static int64 SetDeadLineMs(int64 deadLine, void (*completeHandler)(int64), void (*everyHandler)(int64,int64) = nullptr);/// <summary>/// 设置秒级倒计时/// </summary>/// <param name="t">倒计时秒数</param>/// <param name="completeHandler">完成时回调</param>/// <param name="everyHandler">每秒钟回调</param>/// <returns></returns>static int64 SetCountDown(int64 t, void (*completeHandler)(int64), void (*everyHandler)(int64,int64) = nullptr);/// <summary>/// 设置毫秒级回调/// </summary>/// <param name="t">倒计时毫秒数</param>/// <param name="completeHandler">完成回调</param>/// <param name="everyHandler">每毫秒回调</param>/// <returns></returns>static int64 SetCountDownMs(int64 t, void (*completeHandler)(int64), void (*everyHandler)(int64,int64) = nullptr);/// <summary>/// 设置每秒执行/// </summary>/// <param name="everyHandler">每秒执行的回调</param>/// <param name="t">相隔多少秒执行一次</param>/// <returns></returns>static int64 SetEverySecond(void (*everyHandler)(int64,int64), int32 t = 1);/// <summary>/// 设置每毫秒执行/// </summary>/// <param name="everyHandler">每毫秒执行的回调</param>/// <param name="t">相隔多少毫秒执行一次</param>/// <returns></returns>static int64 SetEveryMs(void (*everyHandler)(int64,int64), int32 t = 1);/// <summary>/// 设置每分钟执行/// </summary>/// <param name="everyHandler">每分钟执行的回调</param>/// <param name="t">相隔多少分钟执行一次</param>/// <returns></returns>static int64 SetEveryMinute(void (*everyHandler)(int64,int64), int32 t = 1);/// <summary>/// 移除已添加的监听/// </summary>/// <param name="id">监听id</param>static void RemoveId(int64 id);/// <summary>/// 清除所有监听/// </summary>static void ClearData();
private:AzhaoTimeMgr();~AzhaoTimeMgr();static AzhaoTimeMgr* _instance;int64 frameTime;TMap<int64, void (*)(int64)> completeHandlers;TMap<int64, int64> completeTimes;TMap<int64, void (*)(int64,int64)> everySecondHandlers;TMap<int64, void (*)(int64,int64)> everyMillisecondHandlers;TMap<int64, void (*)(int64,int64)> everyMinuteHandlers;TMap<int64, int64> everyHandlerTimesMax;TMap<int64, int64> everyHandlerTimes;TMap<int64, TimeCtrlData> addList;int64 timeDifference = 0;int64 lastTime = 0;int64 lastMillisecond = 0;int64 lastMinute = 0;int64 timeId;bool isInit = false;bool isSetServerTime = false;int64 localFrameTime = 0;TSet<int64> delList;int64 updateId = -1;TSet<int64> checkCompleteRemoveList;int64 checkCompleteCt = -1;private:void OnUpdate();void WriteServerTime(int64 t);int64 GetTimeId();void RemoveTime(int64 id);void Init();void Add2AddList(TimeCtrlData data);int64 AddCountDown(int64 sec, void (*completeHandler)(int64), void (*everyHandler)(int64,int64));int64 AddCountDownMs(int64 sec, void (*completeHandler)(int64), void (*everyHandler)(int64,int64));int64 AddDeadLine(int64 deadLine, void (*completeHandler)(int64), void (*everyHandler)(int64,int64));int64 AddSecond(void (*everyHandler)(int64,int64),int32 t);int64 AddMs(void (*everyHandler)(int64,int64), int32 t);int64 AddMinute(void (*everyHandler)(int64,int64), int32 t);void AddOneTimeEvent(TimeCtrlData data);void AddDeadLineFun(TimeCtrlData data);void AddCountDownFun(TimeCtrlData data);void AddCountDownMsFun(TimeCtrlData data);void AddSecond(TimeCtrlData data);void AddMsFun(TimeCtrlData data);void AddMinuteFun(TimeCtrlData data);void Remove(int64 id);void CheckComplete(int64 t);void CheckSecond(int64 t, int64 lt);void CheckMs(int64 t, int64 lt);void CheckMinute(int64 t, int64 lt);void CheckEvery(int64 tid, void(*handle)(int64, int64), int64 leftTime, int64 addtime);bool CheckInDelList(int64 id);void CheckAdd();void CheckDel();void CheckTime();
};
AzhaoTimeMgr* AzhaoTimeMgr::_instance = nullptr;

AzhaoTimeMgr.cpp

#include "Tools/TimeMgr/AzhaoTimeMgr.h"AzhaoTimeMgr::AzhaoTimeMgr()
{frameTime = GetSystemTime();
}AzhaoTimeMgr::~AzhaoTimeMgr()
{
}#pragma region 静态方法AzhaoTimeMgr* AzhaoTimeMgr::GetInstance()
{if (_instance == nullptr){_instance = new AzhaoTimeMgr();}return _instance;
}void AzhaoTimeMgr::Tick()
{AzhaoTimeMgr::GetInstance()->OnUpdate();
}FDateTime AzhaoTimeMgr::GetDateTime()
{return FDateTime::Now();
}int64 AzhaoTimeMgr::GetSystemTime()
{	return (FDateTime::Now() - FDateTime(1970, 1, 1)).GetTotalMilliseconds();//return FDateTime::Now().ToUnixTimestamp();
}int64 AzhaoTimeMgr::GetNowTime()
{int64 t = GetSystemTime();t = (t + GetInstance()->timeDifference) / 1000;return t;
}FDateTime AzhaoTimeMgr::GetDateTimeFromTimestamp(int64 t)
{return FDateTime::FromUnixTimestamp(t);
}FDateTime AzhaoTimeMgr::GetDateTimeFromTimestampMs(int64 t)
{return FDateTime::FromUnixTimestamp(t/1000);
}int64 AzhaoTimeMgr::GetNowTimeMs()
{int64 t = GetSystemTime();t = t + GetInstance()-> timeDifference;return t;
}int64 AzhaoTimeMgr::GetFrameTime()
{return GetInstance()->frameTime;
}void AzhaoTimeMgr::SetServerTime(int64 t)
{GetInstance()->WriteServerTime(t);
}int64 AzhaoTimeMgr::SetDeadLine(int64 deadLine, void (*completeHandler)(int64), void (*everyHandler)(int64,int64))
{return GetInstance()->AddDeadLine(deadLine * 1000, completeHandler, everyHandler);
}int64 AzhaoTimeMgr::SetDeadLineMs(int64 deadLine, void (*completeHandler)(int64), void (*everyHandler)(int64,int64))
{return GetInstance()->AddDeadLine(deadLine , completeHandler, everyHandler);
}int64 AzhaoTimeMgr::SetCountDown(int64 t, void (*completeHandler)(int64), void (*everyHandler)(int64,int64))
{return GetInstance()->AddCountDown(t, completeHandler, everyHandler);
}int64 AzhaoTimeMgr::SetCountDownMs(int64 t, void (*completeHandler)(int64), void (*everyHandler)(int64,int64))
{return GetInstance()->AddCountDownMs(t, completeHandler, everyHandler);
}int64 AzhaoTimeMgr::SetEverySecond(void (*everyHandler)(int64,int64), int32 t)
{return GetInstance()->AddSecond(everyHandler, t);
}int64 AzhaoTimeMgr::SetEveryMs(void (*everyHandler)(int64,int64), int32 t)
{return GetInstance()->AddMs(everyHandler, t);
}int64 AzhaoTimeMgr::SetEveryMinute(void (*everyHandler)(int64,int64), int32 t)
{return GetInstance()->AddMinute(everyHandler, t);
}void AzhaoTimeMgr::RemoveId(int64 id)
{GetInstance()->RemoveTime(id);
}void AzhaoTimeMgr::ClearData()
{GetInstance()->Init();
}#pragma endregion 静态方法void AzhaoTimeMgr::OnUpdate()
{CheckAdd();CheckDel();CheckTime();
}void AzhaoTimeMgr::WriteServerTime(int64 t)
{if (isSetServerTime != true){lastTime = 0;lastMinute = 0;lastMillisecond = 0;isSetServerTime = true;}int64 now = AzhaoTimeMgr::GetSystemTime();timeDifference = t - now;frameTime = AzhaoTimeMgr::GetNowTimeMs();
}int64 AzhaoTimeMgr::GetTimeId()
{timeId++;return timeId;
}void AzhaoTimeMgr::RemoveTime(int64 id)
{delList.Add(id);
}void AzhaoTimeMgr::Init()
{completeHandlers.Empty();completeTimes.Empty();everySecondHandlers.Empty();everyMillisecondHandlers.Empty();everyMinuteHandlers.Empty();everyHandlerTimesMax.Empty();everyHandlerTimes.Empty();delList.Empty();timeDifference = 0;lastTime = 0;lastMillisecond = 0;lastMinute = 0;timeId = 0;isSetServerTime = false;frameTime = AzhaoTimeMgr::GetNowTimeMs();localFrameTime = AzhaoTimeMgr::GetSystemTime();addList.Empty();delList.Empty();checkCompleteRemoveList.Empty();checkCompleteCt = -1;}void AzhaoTimeMgr::Add2AddList(TimeCtrlData data)
{addList.Add(data.id, data);
}int64 AzhaoTimeMgr::AddCountDown(int64 sec, void (*completeHandler)(int64), void (*everyHandler)(int64,int64))
{if (completeHandler == nullptr){return -1;}int64 tid = GetTimeId();int64 now = frameTime;int64 deadline = now + sec * 1000;TimeCtrlData data;data.id = tid;data.type = TimeEventType::countDown;data.deadLine = deadline;data.completeHandler = completeHandler;if (everyHandler != nullptr){data.everyHandler = everyHandler;}Add2AddList(data);return tid;
}int64 AzhaoTimeMgr::AddCountDownMs(int64 sec, void (*completeHandler)(int64), void (*everyHandler)(int64,int64))
{if (completeHandler == nullptr){return -1;}int64 tid = GetTimeId();int64 now = frameTime;int64 deadline = now + sec;TimeCtrlData data;data.id = tid;data.type = TimeEventType::countDownMs;data.deadLine = deadline;data.completeHandler = completeHandler;if (everyHandler != nullptr){data.everyHandler = everyHandler;}Add2AddList(data);return tid;
}int64 AzhaoTimeMgr::AddSecond(void (*everyHandler)(int64,int64),int32 t)
{if (everyHandler == nullptr){return -1;}int64 tid = GetTimeId();TimeCtrlData data;data.id = tid;data.type = TimeEventType::sec;data.everyHandler = everyHandler;data.t = t;Add2AddList(data);return tid;
}int64 AzhaoTimeMgr::AddMs(void (*everyHandler)(int64,int64), int32 t)
{if (everyHandler == nullptr){return -1;}int64 tid = GetTimeId();TimeCtrlData data;data.id = tid;data.type = TimeEventType::ms;data.everyHandler = everyHandler;data.t = t;Add2AddList(data);return tid;
}int64 AzhaoTimeMgr::AddMinute(void (*everyHandler)(int64,int64), int32 t)
{if (everyHandler == nullptr){return -1;}int64 tid = GetTimeId();TimeCtrlData data;data.id = tid;data.type = TimeEventType::minute;data.everyHandler = everyHandler;data.t = t;Add2AddList(data);return tid;
}int64 AzhaoTimeMgr::AddDeadLine(int64 deadLine, void (*completeHandler)(int64), void (*everyHandler)(int64,int64) = nullptr)
{if (deadLine < 0){return -1;}if (completeHandler == nullptr){return -1;}return -1;int64 tid = GetTimeId();TimeCtrlData data;data.id = tid;data.type = TimeEventType::deadLine;data.deadLine = deadLine;data.completeHandler = completeHandler;if (everyHandler != nullptr){data.everyHandler = everyHandler;}Add2AddList(data);return tid;
}void AzhaoTimeMgr::AddOneTimeEvent(TimeCtrlData data)
{int64 eventType = data.type;if (eventType == TimeEventType::deadLine){AddDeadLineFun(data);}else if (eventType == TimeEventType::countDown){AddCountDownFun(data);}else if (eventType == TimeEventType::countDownMs){AddCountDownMsFun(data);}else if (eventType == TimeEventType::sec){AddSecond(data);}else if (eventType == TimeEventType::ms){AddMsFun(data);}else if (eventType == TimeEventType::minute){AddMinuteFun(data);}
}void AzhaoTimeMgr::AddDeadLineFun(TimeCtrlData data)
{int64 tid = data.id;completeHandlers.Emplace(tid, data.completeHandler);completeTimes.Emplace(tid, data.deadLine);if (data.everyHandler != nullptr){everySecondHandlers.Emplace(tid, data.everyHandler);}
}void AzhaoTimeMgr::AddCountDownFun(TimeCtrlData data)
{int64 tid = data.id;completeHandlers.Emplace(tid, data.completeHandler);completeTimes.Emplace(tid, data.deadLine);if (data.everyHandler != nullptr){everySecondHandlers.Emplace(tid, data.everyHandler);}
}void AzhaoTimeMgr::AddCountDownMsFun(TimeCtrlData data)
{int64 tid = data.id;completeHandlers.Emplace(tid, data.completeHandler);completeTimes.Emplace(tid, data.deadLine);if (data.everyHandler != nullptr){everyMillisecondHandlers.Emplace(tid, data.everyHandler);}
}void AzhaoTimeMgr::AddSecond(TimeCtrlData data)
{int64 tid = data.id;everySecondHandlers.Emplace(tid, data.everyHandler);everyHandlerTimes.Emplace(tid, 0);everyHandlerTimesMax.Emplace(tid, data.t);
}void AzhaoTimeMgr::AddMsFun(TimeCtrlData data)
{int64 tid = data.id;everyMillisecondHandlers.Emplace(tid, data.everyHandler);everyHandlerTimes.Emplace(tid, 0);everyHandlerTimesMax.Emplace(tid, data.t);
}void AzhaoTimeMgr::AddMinuteFun(TimeCtrlData data)
{int64 tid = data.id;everyMinuteHandlers.Emplace(tid, data.everyHandler);everyHandlerTimes.Emplace(tid, 0);everyHandlerTimesMax.Emplace(tid, data.t);
}void AzhaoTimeMgr::Remove(int64 id)
{if (completeHandlers.Contains(id)){completeHandlers.Remove(id);}if (completeTimes.Contains(id)){completeTimes.Remove(id);}if (everySecondHandlers.Contains(id)){everySecondHandlers.Remove(id);}if (everyMillisecondHandlers.Contains(id)){everyMillisecondHandlers.Remove(id);}if (everyMinuteHandlers.Contains(id)){everyMinuteHandlers.Remove(id);}if (everyHandlerTimesMax.Contains(id)){everyHandlerTimesMax.Remove(id);}if (addList.Contains(id)){addList.Remove(id);}
}void AzhaoTimeMgr::CheckComplete(int64 t)
{if (completeHandlers.Num() == 0){return;}checkCompleteRemoveList.Empty();checkCompleteCt = -1;for (auto& item : completeHandlers){int64 key = item.Key;if (CheckInDelList(key)){continue;}if (completeTimes.Contains(key)){checkCompleteCt = completeTimes[key];if (checkCompleteCt < t){item.Value(key);checkCompleteRemoveList.Add(key);}}if (checkCompleteRemoveList.Num() > 0){for (auto& item2 : checkCompleteRemoveList){delList.Add(item2);//Remove(item2);}}}
}void AzhaoTimeMgr::CheckSecond(int64 t, int64 lt)
{if (everySecondHandlers.Num() == 0){return;}int64 passTime = lt - lastTime;if (passTime > 1000){int64 leftTime = -1;for (auto& item : everySecondHandlers){int64 key = item.Key;if (CheckInDelList(key) == true){continue;}leftTime = 0;if (completeTimes.Contains(key) == true){leftTime = (*completeTimes.Find(key)-t)/1000;}CheckEvery(item.Key, item.Value, leftTime, passTime / 1000);}lastTime = lt;}
}void AzhaoTimeMgr::CheckMs(int64 t, int64 lt)
{if (everyMillisecondHandlers.Num() == 0){return;}int64 PassTime = lt - lastMillisecond;if (PassTime > 0){int64 leftTime = 0;for (auto& item : everyMillisecondHandlers){int64 key = item.Key;if (CheckInDelList(key)){continue;}leftTime = 0;if (completeTimes.Contains(key)){leftTime = (*completeTimes.Find(key)) - t;}CheckEvery(item.Key, item.Value, leftTime, PassTime);}lastMillisecond = lt;}
}void AzhaoTimeMgr::CheckMinute(int64 t, int64 lt)
{if (everyMinuteHandlers.Num() == 0){return;}int64 passTime = lt - lastMinute;if (passTime >= 60000){int64 leftTime = 0;for (auto& item : everyMinuteHandlers){int64 key = item.Key;if (CheckInDelList(key)){continue;}leftTime = 0;if (completeTimes.Contains(key)){leftTime = (*completeTimes.Find(key) - t) / 60000;}CheckEvery(item.Key, item.Value, leftTime, passTime / 60000);}lastMinute = lt;}
}void AzhaoTimeMgr::CheckEvery(int64 tid, void(*handle)(int64, int64), int64 leftTime, int64 addtime)
{int64 tInd = 0;if (everyHandlerTimes.Contains(tid)){tInd = *everyHandlerTimes.Find(tid);}int64 tMax = 1;if (everyHandlerTimesMax.Contains(tid)){tMax = *everyHandlerTimesMax.Find(tid);}		tInd = tInd + addtime;;if (tInd >= tMax){if (everyHandlerTimes.Contains(tid)){everyHandlerTimes.Remove(tid);}handle(tid, leftTime);}else{everyHandlerTimes.Emplace(tid, tInd);}}bool AzhaoTimeMgr::CheckInDelList(int64 id)
{if (delList.Num() == 0){return false;}if (delList.Contains(id)){return true;}else{return false;}
}void AzhaoTimeMgr::CheckAdd()
{int32 num = addList.Num();if (num == 0){return;}for (auto& item : addList){AddOneTimeEvent(item.Value);}addList.Empty();
}void AzhaoTimeMgr::CheckDel()
{if (delList.Num() == 0){return;}for (auto& item : delList){Remove(item);}delList.Empty();
}void AzhaoTimeMgr::CheckTime()
{frameTime = AzhaoTimeMgr::GetNowTimeMs();localFrameTime = AzhaoTimeMgr::GetSystemTime();if (lastTime == 0){lastTime = localFrameTime;}if (lastMillisecond == 0){lastMillisecond = localFrameTime;}if (lastMinute == 0){lastMinute = localFrameTime;}CheckComplete(frameTime);CheckSecond(frameTime, localFrameTime);CheckMs(frameTime, localFrameTime);CheckMinute(frameTime, localFrameTime);
}TimeCtrlData.h
#pragma once#include "CoreMinimal.h"
/*** */
class UECPPTEST_API TimeCtrlData
{
public:TimeCtrlData();~TimeCtrlData();int32 type;int64 deadLine;void(*completeHandler)(int64) = nullptr;void (*everyHandler)(int64,int64) = nullptr;int64 id;int32 t;};TimeEventType.h#pragma once#include "CoreMinimal.h"/*** */
class UECPPTEST_API TimeEventType
{
public:TimeEventType();~TimeEventType();static const int32 deadLine = 0;static const int32 countDown = 1;static const int32 countDownMs = 2;static const int32 sec = 3;static const int32 ms = 4;static const int32 minute = 5;
};

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/842981.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【文末附gpt升级秘笈】苹果与OpenAI携手,ChatGPT将登陆iOS 18的深远影响

苹果与OpenAI携手&#xff0c;ChatGPT将登陆iOS 18的深远影响 一、引言 随着人工智能技术的飞速发展&#xff0c;自然语言处理&#xff08;NLP&#xff09;已成为当下最热门的研究领域之一。在这一领域&#xff0c;OpenAI的ChatGPT模型凭借其卓越的性能和广泛的应用前景&…

8个最佳实践,助你打造成功的短剧平台开发团队

当涉及到跨境电商平台开发&#xff0c;成功的团队至关重要。在这篇文章中&#xff0c;我将分享8个最佳实践&#xff0c;助你打造成功的短剧平台开发团队。无论是经验丰富的团队还是初创企业&#xff0c;这些实践都能为你的团队带来价值&#xff0c;提高开发效率&#xff0c;确保…

lua 计算第几周

需求 计算当前赛季的开始和结束日期&#xff0c;2024年1月1日周一是第1周的开始&#xff0c;每两周是一个赛季。 lua代码 没有处理时区问题 local const 24 * 60 * 60 --一整天的时间戳 local server_time 1716595200--todo:修改服务器时间 local date os.date("*t…

快速复制成功模式:解读SaaS裂变工具的核心价值

在数字化快速发展的今天&#xff0c;企业如何在竞争激烈的市场中迅速站稳脚跟&#xff0c;成为许多企业家和管理者关注的焦点。SaaS裂变工具作为一种创新的解决方案&#xff0c;以其独特的优势&#xff0c;帮助企业快速复制成功模式&#xff0c;实现业务的快速增长。 SaaS裂变工…

Mysql 单行转多行,把逗号分隔的字段拆分成多行

一、拆分前后的数据 二、执行SQL select substring_index(substring_index(a.gzlx,,,b.help_topic_id1),,,-1) gzlxname, a.gzlx,a.* from dt_task_zxgz_info a join mysql.help_topic b on b.help_topic_id < (length(a.gzlx) - length(replace(a.gzlx,,,))1) 三、解释说…

cobalt strike基础测试

下载链接4.3&#xff1a;https://pan.baidu.com/s/1E_0t30tFWRiE5aJ7F-ZDPg 链接4.0&#xff1a;https://pan.baidu.com/s/1SkMmDem3l6bePqIDgUz2mA 提取码&#xff1a;burp 一、简介&#xff1a; cobalt strike(简称CS)是一款团队作战渗透测试神器&#xff0c;分为客户端…

使用大模型LLM实现销售AI

想象一个场景&#xff0c;客户通过聊天窗口咨询一款产品。销售AI首先使用LLM解析客户的问题&#xff0c;然后通过智能代理查询数据库获取产品详细信息&#xff0c;并以自然而友好的方式回应客户。 在对话过程中&#xff0c;AI可以评估客户的兴趣&#xff0c;并主动提供促销信息…

905. 按奇偶排序数组 - 力扣

1. 题目 给你一个整数数组 nums&#xff0c;将 nums 中的的所有偶数元素移动到数组的前面&#xff0c;后跟所有奇数元素。 返回满足此条件的 任一数组 作为答案。 2. 示例 3. 分析 开辟一个数组res用来保存操作过后的元素。第一次遍历数组只插入偶数&#xff0c;第二次遍历数组…

查分小程序怎么用?

在教育信息化的浪潮中&#xff0c;一种新型的成绩管理工具成绩发布小程序&#xff0c;正逐渐成为教师的得力助手。简化了成绩发布流程&#xff0c;还提高了信息的安全性和便捷性。 查分小程序的使用方法非常直观。只需在威信中搜索并打开易查分小程序&#xff0c;教师按照提示注…

渠道品牌展示与营销合规性第三方监测内容(专业神秘顾客调研)

渠道品牌展示与营销合规性监测是指通过对销售渠道&#xff08;如零售店、经销商、线上平台等&#xff09;的品牌展示和营销活动进行监督和评估&#xff0c;以确保这些活动符合企业的品牌标准、营销策略和相关法规要求。这种监测帮助企业维护品牌形象、提升市场竞争力&#xff0…

代码随想录算法训练营第四十二天|62.不同路径、63. 不同路径 II

代码随想录算法训练营第四十二天 62.不同路径 题目链接&#xff1a;62.不同路径 确定dp数组以及下标的含义&#xff1a;到[i,j]点位有dp[i,j]条路径确定递推公式&#xff1a;每个点位都可以从它上面一个位置或者左边一个位置到达&#xff0c;所以路径数量等于上面位置的路径…

在JavaScript中如何移除数组中的特定项

在日常开发中,我们经常需要从数组中移除某个特定的元素。在JavaScript中,存在多种不同的方法来完成这一任务,本文将总结几种常见的处理方式,并介绍它们的优缺点。 常规情况 1. 使用 .splice() 方法按值移除数组元素 是否修改原数组: 是是否移除重复项: 是(使用循环), 否…

IP协议说明

文章目录 前言一、IP协议的简介二、IP数据报1.IP 数据报结构2.IP 数据报的分片解析3.IP 数据报的分片重装 三、IP 数据报的输出四、IP 数据报的输入 前言 IP 指网际互连协议&#xff0c; Internet Protocol 的缩写&#xff0c;是 TCP/IP 体系中的网络层协议。设计 IP 的目的是…

python改进婚礼礼金请帖

# 改进婚礼礼金程序 # 。用“w”模式&#xff0c;打开一个文件“婚礼礼金.txt” # 。写一个while ture # 。请输入”姓名&#xff0c;礼金“&#xff0c;例如”小明 1000“ # 。将数据存储入文件中&#xff0c;每行一个数据 # 。输入quit 退出循环 # 。退出循环重新读取文件&am…

Python面试宝典:Python中与FastApi相关的面试笔试题(1000加面试笔试题助你轻松捕获大厂Offer)

Python面试宝典:1000加python面试题助你轻松捕获大厂Offer【第二部分:Python高级特性:第十六章:Web开发:第三节:FastApi】 第十六章:Web开发第三节:FastApi特性快速入门路径操作装饰器请求数据和类型转换响应模型依赖注入异步支持安全性和认证面试题1面试题2面试题3面试…

(二刷)代码随想录第16天|104.二叉树的最大深度 559.n叉树的最大深度● 111.二叉树的最小深度● 222.完全二叉树的节点个数

104.二叉树的最大深度 104. 二叉树的最大深度 - 力扣&#xff08;LeetCode&#xff09; 代码随想录 (programmercarl.com) 后序遍历&#xff1a; class Solution {public int maxDepth(TreeNode root) {// 如果当前节点为空&#xff0c;深度为0if (root null) {return 0;}// …

SQL数据分析常用函数

SQL 中有许多常用的函数&#xff0c;可以用于处理和操作数据。以下是一些常见的SQL 函数&#xff1a; 1. 字符串函数&#xff1a; CONCAT(str1, str2, …): 用于把多个文本字符串合并成一个长字符串(参数中有null时返回null)。 select concat(一起,学, SQL); -- 输出结果:一…

#经验分享#学习方法

大鱼论文是一款强大的论文写作&#xff0c;查重降重工具&#xff0c;在众多同类软件中脱颖而出&#xff0c;备受好评。那么&#xff0c;大鱼论文究竟好不好用呢&#xff1f;让我们来看看。 首先&#xff0c;大鱼论文非常方便易用。只需简单几步&#xff0c;就可以上传文档进行…

RPC 框架

RPC 全称 Remote Procedure Call——远程过程调用。 RPC技术简单说就是为了解决远程调用服务的一种技术&#xff0c;使得调用者像调用本地服务一样方便透明。RPC是一种通过网络从远程计算机程序上请求服务&#xff0c;不需要了解底层网络技术的协议。 集群和分布式 集群&…

基于Freertos的工训机器人

一. 工训机器人 V1 1. 实物 将自制的F4开发板放置车底板下方&#xff0c;节省上方空间&#xff0c;且能保证布线方便整齐。 2. SW仿真 使用SolidWorks进行仿真&#xff0c;且绘制3D打印件。 工训仿真 3.3D打印爪测试 机械爪测试 二. 工训机器人 V2 1. 实物 工训机器人V2不同于…