:: 1
地址是环回地址,带有该地址的数据包在主机外部的网络上不存在。它不能用作网络上的源或目标地址。我认为您打算使用 ::
未指定的地址,该地址将在所有主机地址上收听。
有时,您需要最新版本的Angular和迁移配置。
例如,假设 Angular 17.1于2024年1月17日发布,,但截至今天(1月22日),最后一个可用版本根据Angular和Nx版本矩阵 IS:
Angular Version Nx Version
~17.0.0 17.1.0 <= latest
也许您已经使用了这些命令(如NX)
# Update Nx to the latest version
nx update @nrwl/workspace
# Migrate Nx to the latest version
nx migrate latest
# If migration.json is created
nx migrate --run-migrations=migrations.json
# Update all packages to the latest version
npm install
:流程已将您的设置更新为版本17.0.0,,但要立即使用Angular 17.1(最新的版本)。
在这种情况下,您可以尝试:
npx npm-check-updates -u
npm i --legacy-peer-deps
第一个命令将您的 package.json
更新为最新的软件包版本,而第二个命令则负责安装更新,以尊重必要的同行依赖关系。
使用 - 传统peer-deps
可以通过绕过对等自动安装来帮助您。在处理版本不匹配或未匹配的同伴依赖性时,它特别有用。
但是没有保证,每次都可以工作。在尝试这样做之前,最好使用版本控制系统(例如Git)。
ps我今天可以成功地升级到Angular 17.1。
如果您只想运行一次(第一个Prop值),则只需删除依赖项并留下空数组 - useffect(()=&gt; ...,[])
。如果问题是第一个值可能是空数组或未定义的,则在Useref中引入稳定的常数并在使用效果中填充它,但只有以前没有填充,并且像这样,您将在参考中只有第一个有效的值。
这样的东西?:
SP500 = ['MSFT', 'AAPL', 'AMZN', 'TSLA', 'GOOGL', 'GOOG', 'FB']
weight500 = [6, 5.9, 3, 2.5, 2.3, 2.1, 2]
SP_wight_dict = dict(zip(SP500, weight500))
portfolio = ['MSFT', 'GOOGL', 'GOOG']
for i in portfolio:
print(f"Weight = {SP_wight_dict[i]}, Index = {SP500.index(i)}")
下一条言论的一线式
一线似乎似乎是多余的,但实际上它们在那里覆盖边缘案例。
// Length fixed at "50"
const trim50 = str => str?.match(/^.{0,50}.*?(?=\b| |$)/)[0];
// Dynamic length
const trim = (str, n) => new RegExp(`^.{0,${n}}.*?(?=\b| |$)`).exec(str)[0];
// Demo
console.log(trim('Contrary to popular belief, Lorem Ipsum is not simply text', 50))
无正
const trim = (str, n) => {
const start = str.substring(0, n);
const index = str.indexOf(' ', n - 1);
const end = str.slice(n, index < 0 ? str.length : index);
return start + end;
}
console.log(trim('Contrary to popular belief, Lorem Ipsum is not simply text', 50));
测试案例
由于SO内置控制台的局限性, ,请使用F12提升DevTools的控制台,然后然后 运行以下代码以进行一些演示。
const testCases = [
{ input: 'Contrary to popular belief, Lorem Ipsum is not simply text',
expected: 'Contrary to popular belief, Lorem Ipsum is not simply' },
{ input: '1234 6789 1234 6789 1234 6789 1234 6789 1234 678901234 6789',
expected: '1234 6789 1234 6789 1234 6789 1234 6789 1234 678901234' },
{ input: '1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789',
expected: '1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 ' },
{ input: '1234 6789 1234 6789 1234 6789 1234 6789 1234 67890123456789',
expected: '1234 6789 1234 6789 1234 6789 1234 6789 1234 67890123456789' },
{ input: ' ',
expected: ' ' },
{ input: '1234 5678',
expected: '1234 5678' },
{ input: '1234',
expected: '1234' },
{ input: '',
expected: '' }
];
const test = trim => {
console.table(
testCases.map(
testCase => Object.assign(
Object.assign(testCase, { output: trim(testCase.input) }),
{ pass: testCase.output === testCase.expected }
)
)
);
};
test(str => str?.match(/^.{0,50}.*?(?=\b| |$)/)[0]);
尝试此而不是 scanfiles
:
bootstrapFiles:
- /app/vendor/bin/.phpunit/phpunit-9.5-0/vendor/autoload.php
您的初始状态是错误的。虚拟API返回“数据”字段下的数组,因此您需要在初始状态下匹配该结构。
this.state = {
menu:false,
userData:{ data: [] }
}
我认为这就是您想做的。这使用状态变量来跟踪执行器所处的状态。
执行器关闭后,循环将检查温度,如果温度高于27度,它将开始打开执行器。然后,循环将简单地使用Millis()监视时间,直到执行器打开为止 - 因此您可以将其他代码放入其他传感器的循环中。
如果执行器打开,也会发生同样的情况,当温度低于26度时,它将关闭执行器(在此处保持差异,以阻止代码不断触发,如果温度悬停在27度左右)。
当前,这将在执行器开放或关闭时读取循环的每一个迭代的温度 - 因此,我在循环末端放了一个小延迟以限制这一点。
请注意 - 由于没有硬件可以交付,我尚未测试代码中的任何更改。但是它会编译,并应该让您了解如何使用 millis()
使用状态模型来处理此类事情,而不会延迟循环。
#include <Adafruit_BME280.h>
#include <WiFi.h>
const char* ssid = "#####"; // ESP32 and ESP8266 uses 2.4GHZ wifi only
const char* password = "#####";
//MQTT Setup Start
#include <PubSubClient.h>
#define mqtt_server "####.###.##.##"
WiFiClient espClient;
PubSubClient client(espClient);
#define mqttActuator "growShed/Acuator"
#define mqttTemp1 "growShed/temp1"
int actuatorUp = 15; //GPIO de l'actuator
int actuatorDown = 2; //GPIO de l'actuator
int actuatorUpread = (!digitalRead(actuatorUp)); //read state of gpio : on or off
int actuatorDownread = (!digitalRead(actuatorDown)); //read state of gpio : on or off
//MQTT Setup End
Adafruit_BME280 bme1; // I2C
//utiliser les virgules sur les capteurs suivants
float temp1, hum1, pres1;
//gestion des délais entre chaque captations de data
unsigned long millisNow1 = 0; //for delay purposes (laisser 0)
unsigned int sendDelay1 = 2000; //delay before sending sensor info via MQTT
//gestion des délais entre chaque captations de data
unsigned long millisNow3 = 0; //for delay purposes (laisser 0)
unsigned int sendDelay3 = 7000; //delay before sending sensor info via MQTT
// The states the actuator can be in.
enum ActuatorState
{
OPENING,
OPEN,
CLOSING,
CLOSED
};
ActuatorState actuatorState;
// When opening or closing the actuator - this is the time to stop.
unsigned long actuatorEndTime = 0 ;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println();
// begin Wifi connect
Serial.println("Connecting to ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(2000);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.println(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address (wifi RaspPi) : ");
Serial.println(WiFi.localIP());
//end Wifi connect
client.setServer(mqtt_server, 1883);
//BME
delay(5000);
unsigned status;
status = bme1.begin(0x76);
if (!status) {
Serial.println("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");
Serial.print("SensorID was: 0x"); Serial.println(bme1.sensorID(),16);
Serial.print(" ID of 0xFF probably means a bad address, a BMP 180 or BMP 085\n");
Serial.print(" ID of 0x56-0x58 represents a BMP 280,\n");
Serial.print(" ID of 0x60 represents a BME 280.\n");
Serial.print(" ID of 0x61 represents a BME 680.\n");
while (1);
}
//Acuator
pinMode(actuatorUp, OUTPUT);
digitalWrite(actuatorDown, HIGH); //Begin with actuator switched off
pinMode(actuatorDown, OUTPUT);
digitalWrite(actuatorUp, HIGH); //Begin with actuator switched off
actuatorState = CLOSED ;
//End Actuator
}
bool getValues() {
temp1 = round(bme1.readTemperature()); //rounded values
actuatorUpread = (digitalRead(actuatorUp)); //inverted value as the relay is inverted
Serial.print("BME 1 Temperature = ");
Serial.print(temp1);
Serial.println(" °C");
Serial.print("État de l'actuator haut = ");
Serial.println(actuatorUpread);
Serial.print("État de l'actuator bas = ");
Serial.print(actuatorDownread);
Serial.println();
}
void reconnect() {
// Loop until we're reconnected
int counter = 0;
while (!client.connected()) {
if (counter==5){
ESP.restart();
}
counter+=1;
Serial.println("Attempting MQTT connection...");
// Attempt to connect
if (client.connect("growTentController")) {
Serial.println("connected");
} else {
Serial.println("failed, rc=");
Serial.println(client.state());
Serial.println(" try again in 5 seconds");
// Wait 10 seconds before retrying
delay(5000);
}
}
}
void loop() {
// put your main code here, to run repeatedly:
if (!client.connected()){
reconnect();
}
if (millis() > millisNow1 + sendDelay1){
if (getValues()) {
client.publish(mqttTemp1, String(temp1).c_str(),true);
client.publish(mqttActuator, String(actuatorUpread).c_str(),true);
millisNow1 = millis();
}
}
//Acuator moving according to BME280 temperature sensor
switch ( actuatorState ) {
case OPEN:
// Does it need closing (use value lower than 27 so we're not constantly opening and
// closing the actuator if the temperature is floating around 27)
temp1 = bme1.readTemperature();
if ( temp1 < 26 ) {
digitalWrite(actuatorDown, LOW);
actuatorState = CLOSING;
actuatorEndTime = millis() + 7000 ;
}
break;
case CLOSED:
// Does it need opening?
temp1 = bme1.readTemperature();
if ( temp1 > 27 ) {
digitalWrite(actuatorUp, LOW);
actuatorState = OPENING;
actuatorEndTime = millis() + 7000;
}
break ;
case OPENING:
// Is it fully open?
if ( millis() >= actuatorEndTime ) {
digitalWrite(actuatorUp, HIGH);
actuatorState = OPEN ;
}
break ;
case CLOSING:
// Is it fully closed?
if ( millis() >= actuatorEndTime ) {
digitalWrite(actuatorDown, HIGH);
actuatorState = CLOSED ;
}
break ;
}
// small delay to run the loop - and do the temperature check 5 times per second.
delay(200);
}
这归结为IMO的是R和(基于C的)Numpy阵列的方式:R-列首先,Numpy-首先。
一个简单的解决方案是转置您的numpy数组:
np_data_measurment.transpose((2,1,0))
这将为您提供与R相同的显示。
array([[[ 1., 2., 3., 4.],
[ 5., 6., 7., 8.],
[ 9., 10., 11., 12.]],
[[ 10., 20., 30., 40.],
[ 50., 60., 70., 80.],
[ 90., 100., 110., 120.]]])
只要您不将此转换阵列放回R中,您就可以了。 (如果您这样做,则需要重新翻新。)
要用一个实际值替换占位符,您需要用参数调用构建
String url = "http://example.com/{id}";
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(url);
URI uri = builder.build("12");
System.out.println(uri);
您需要转换并执行 获得上一个出发日期:
# arrival
a = pd.to_datetime(df_corp['arrival_date'], dayfirst=True)
# previous departure per ID
l = pd.to_datetime(df_corp['leaving_date'], dayfirst=True).groupby(df_corp['ID']).shift()
# difference in days
df_corp['time_between'] = (a-l).dt.days
输出:
ID arrival_date leaving_date time_between
0 1 01/02/20 05/02/20 NaN
1 2 01/03/20 07/03/20 NaN
2 1 12/02/20 20/02/20 7.0
3 1 07/03/20 10/03/20 16.0
4 2 10/03/20 15/03/20 3.0
正如@arundeep Chohan一样,正确指出了Web驱动程序在来回移动时丢失参考,因此我必须重新抓住所有元素。
正确的代码是:
def get_all_events_in_each_event(self):
inner_events = self.get_all_inner_events()
for i in range(len(inner_events)):
self.click_inner_event(inner_events[i])
self.get_event_loc()
self.get_talent()
self.get_facebook()
self.get_date()
self.get_showtime_city()
self.get_ticket_doors()
self.back()
inner_events = self.get_all_inner_events() #regrabbing the elements
感谢Arundeep的答案。
学习 awk
和 SED
仅适合这种情况的强大工具。
你跑地平线吗?如果您将事件发送到后台,则需要地平线
Do you run horizon? If you sent event to background you need horizon
如何在命令内核中使用工作?