似乎与C#脚本中的日期时间解析问题有关,导致脚本无法正确识别日期时间字符串

BUG反馈 · 139 次浏览
泥点子 创建于 2023-09-03 05:40
运行子程序(搭建最小独立环境,运行Python代码)失败。解析表达式出错。
内部错误:该字符串未被识别为有效的 DateTime。
原始表达式:{
// 公用状态变量,统一保存在Minipython目录
string JSONFile=Path.Combine({WD},"action.json");
if(File.Exists(JSONFile))
{
string JSON=File.ReadAllText(JSONFile);
_context.UpdateVariablesFromJson(JSON);
}
 
 
// 每个动作独立状态变量,单独保存在_context.ActionTitle目录
string tempWD=Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),"Quicker",_context.ActionTitle);
if(!Directory.Exists(tempWD)) Directory.CreateDirectory(tempWD);
string tempJSONFile=Path.Combine(tempWD,"action_sep.json");
if(File.Exists(JSONFile) && File.Exists(tempJSONFile))
{
 
string JSON=File.ReadAllText(tempJSONFile);
JObject jobj=JObject.Parse(JSON);
// 如果其他动作重装Python了,则重新检测本动作是否需要安装其必备工具包
string PythonInstallTime=(string)_context.GetVarValue("PythonInstallTime");
if(string.IsNullOrEmpty(PythonInstallTime) || !jobj.ContainsKey("PythonInstallTime") ){
_context.SetVarValue("是否安装工具包",false);
return;
}
if(DateTime.Parse(PythonInstallTime)> DateTime.Parse((string)jobj["PythonInstallTime"])+ new TimeSpan(0,0,1)){
_context.SetVarValue("是否安装工具包",false);// 重新检测
} else {
_context.UpdateVariablesFromJson(JSON);
}
}
 
 
}(赋值)
(----CNKI文献更新v8:运行子程序----)

回复内容
暂无回复
回复主贴