我不是打字稿的专家,但是当我尝试使用纯JS时,它也可以使用。
const fs = require("fs");
const readMD = (filePath) => {
return new Promise((resolve, reject) => {
fs.readFile(filePath, "utf8", (error, content) => {
if (error) reject(error);
resolve(content);
});
});
}
readMD("./changelog.md").then(changelog => {
const result = changelog.match(/^##.*\n([^#]*)/m);
console.log(result[1]);
});
使用传输状态将数据保存到服务器端。一旦加载浏览器,您就可以从传输状态获取数据。
服务器端接收数据并打印数据,但要将数据放在客户端上,您必须存储它的传输状态。代码应像
constructor(
@Optional() @Inject('MODEL') private model: string,
@Inject(PLATFORM_ID) private _platformId: Object,) {
}
ngOnInit(): void {
if (isPlatformServer(this._platformId)) {
this.transferState.set(makeStateKey('model'), this.model);
} else if (isPlatformBrowser(this._platformId)) {
this.model= this.transferState.get(makeStateKey('model'), null)
}
}
简单的解决方案可以将JSON转换为C#对象,然后在操作上迭代并读取其描述属性,如下所示:
Root myDeserializedObject = JsonConvert.DeserializeObject<Root>(myJsonResponse);
foreach(var item in myDeserializedObject.operations)
{
Console.WriteLine(item.description);
}
从JSON String中生成这些C#对象,来自: https://json2csharp.com/
public class ComCumulocityModel
{
public string op { get; set; }
public string param { get; set; }
public string value { get; set; }
public int? Mode { get; set; }
public string StopStationPayload { get; set; }
}
public class Operation
{
public DateTime creationTime { get; set; }
public string deviceId { get; set; }
public string deviceName { get; set; }
public string status { get; set; }
public ComCumulocityModel com_cumulocity_model { get; set; }
public string description { get; set; }
}
public class Root
{
public List<Operation> operations { get; set; }
public Statistics statistics { get; set; }
}
public class Statistics
{
public int currentPage { get; set; }
public int pageSize { get; set; }
}
GO不是SQL命令。
只有SQL命令可以需要一个“”;
GO是由SSM而不是SQL Server执行的命令。
Go是批处理命令的分离器。
Go Say to to ssms将命令扔到SQL Server,然后将其返回时,继续抛出命令,直到找到新的GO语句为止。
在Intellij中,当您创建一个类时,它的软件包将自动创建。
只需右键单击 src/java
目录,然后进行“新 - &gt; java类”。输入新类的包装合格名称,并将创建所有缺失的软件包:
例如,假设我没有文件夹a,b,c,c,d,e,除了文件foo.java之外,还将创建所有这些。
以下方法有点冗长,但是您可以使用bash Regex提取日期零件,而 case
转换月的开关:
#!/bin/bash
filename='SomeFilename 05 May 2022.zip'
if [[ $filename =~ ([0-9]{2})\ ([A-Z][a-z]{2})\ ([0-9]{4})\.[^.]+$ ]]
then
d=${BASH_REMATCH[1]}
case ${BASH_REMATCH[2]} in
Jan) m=01;; Feb) m=02;; Mar) m=03;;
Apr) m=04;; May) m=05;; Jun) m=06;;
Jul) m=07;; Aug) m=08;; Sep) m=09;;
Oct) m=10;; Nov) m=11;; Dec) m=12;;
esac
y=${BASH_REMATCH[3]}
date=$d$m$y
fi
如果我正确理解您,您想要的是一个列表,其中包含CSV文件中所有pandas数据范围的列表。因此,帧
是一个列表,逐步将所有dataframes df
附加到。它们可以通过框架[index]
访问它们
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
number_of_files = 10
frames = []
filename = "your_file{number}.csv" # In your case: "Cuerpo Negro {number} Volt.txt"
for i in range(1, number_of_files+1):
df = pd.read_csv(filename.format(number=i), skiprows=1)
frames.append(df)
您可以包装另一个查询吗?
喜欢:
select *
from(
SELECT thedate, thedata FROM table
GROUP BY strftime("%%Y-%%m", date)
ORDER BY max(strftime("%%Y-%%m", date)) DESC
LIMIT 3
) details
order by details.thedate
useaxios
正如您所设计的,是一个钩子。钩子应遵循一些规则,称为挂钩规则,这里是概述:
它应该只能被称为a反应组件的级别或钩子的顶层,而不是像您一样在钩子或组件内的功能中,而不是在任何其他块中,例如if-else。 ..
它 为您的情况征收可能是这样的:
import { useContext, useState, useEffect } from 'react';
import './login.scss';
import { useNavigate } from 'react-router-dom';
import { useAxios } from '../../api/use-axios';
import ApiConfig from '../../api/api-config';
import { AuthContext } from '../../context/AuthContext';
const LOGIN_AXIOS_CONFIG = ApiConfig.AUTH.LOGIN;
const Login = () => {
const [loginAxioConfig, setLogicAxiosConfig]=useState(null);
const [loginError, setLoginError] = useState('');
const [phone, setPhone] = useState('');
const [password, setPassword] = useState('');
const { response: loginData, error } = useAxios(loginAxioConfig);
const navigate = useNavigate();
const { dispatch } = useContext(AuthContext);
const handleLogin = (e) => {
e.preventDefault();
setLogicAxiosConfig({...LOGIN_AXIOS_CONFIG, data = {
phone,
password,
} });
};
useEffect(()=>{
if (error) {
setLoginError(error);
}
},[error]);
useEffect(()=>{
if (loginData) {
dispatch({ type: 'LOGIN', payload: loginData });
navigate('/');
}
},[loginData])
return (
<div className="login">
<div className="logo">
<h1>LOGO</h1>
<h3>LOGO DESCRIPTION</h3>
</div>
<form onSubmit={handleLogin}>
<input type="number" placeholder="phone" onChange={(e) => setPhone(e.target.value)} />
<input type="password" placeholder="password" onChange={(e) => setPassword(e.target.value)} />
<button type="submit">Submit</button>
{loginError && <span>{loginError}</span>}
</form>
</div>
);
};
export default Login;
import { useState, useEffect } from 'react';
import axios from 'axios';
export const useAxios = (axiosParams) => {
const [response, setResponse] = useState(undefined);
const [error, setError] = useState('');
const [loading, setLoading] = useState(true);
const fetchData = async (params) => {
try {
const result = await axios.request({
...params,
method: params.method || 'GET',
headers: {
accept: 'application/json',
authorization:
'Bearer my-token',
},
});
console.log(result.data);
setResponse(result.data);
} catch (error) {
setError(error);
} finally {
setLoading(false);
}
};
useEffect(() => {
if(!axiosParams) return;
fetchData(axiosParams);
}, [axiosParams]);
return { response, error, loading };
};
我们可以尝试使用子查询来计算 sum
窗口功能之前的每个月销售。
SELECT t1.*,sum(total_sales) over(order by month) as cum_sum
FROM (
select month, sum(sales) total_sales
from sales
group by month
) t1
lowestPrice = min(allproducts.items(),key = lambda x:x [1])
正在返回元组(product_name,product_price)
。 lowestPrice = min(allproducts.items(),key = lambda x:x [1])[1]
将仅返回价格,然后一切正常。
基本上总是以8
的长度返回
这是格式字符串所做的:
>>> print(f"{'C30':>08s}")
00000C30
作为旁注,以将任何数字输出为8位十六进制:
>>> print(f"{100:>08X}")
00000064
>>> print(f"{1024:>08X}")
00000400
请参阅文档:
据我所知,没有开箱即用的解决方案,您应该在运行
docker exec的容器上执行自己的API执行命令。 &lt;命令&gt;
并返回输出,Mind逃脱命令。但是,您应该知道,让用户在Docker内运行命令很危险,因为它可能会影响您的主机。
From what I know there is no out of the box solution, you should make your own api executing command on your container running
docker exec <id> <command>
and returning the output, mind escape the command.However you should know that letting a user run commands inside a docker is dangerous as it could impact your host.
如何从Web连接到Docker容器?