我有这个脚本:
@echo off
Ping www.google.nl -n 1 -w 1000 >nul 2>nul
if errorlevel 1 (set internet=Nao conectado) else (set internet=Connectado) >nul 2>nul
echo %internet%
if %internet%=Nao conectado goto 1
if %internet%=Conectado goto 2
:1 exit
:2
echo hi
pause
但是条件if %internet%
无效。怎么了?
答案 0 :(得分:2)
IF
命令有两件事。
1)如果您阅读了帮助文件,您会注意到字符串比较的语法要求使用两个等号。
2)如果需要比较带空格的字符串,则需要用引号将比较括起来。
if "%internet%"=="Nao conectado" goto 1
答案 1 :(得分:2)
我想您可以简化它,而不是不必要地设置变量:
df <- data.frame(
date = seq(as.Date("2018/01/01"), by = "day", length.out = 20),
val = sample(1:10, 20, replace=TRUE)) %>%
mutate(weekday = strftime(date,'%A'))
date val weekday val_recent
1 20/01/2018 4 Saturday 4
2 19/01/2018 3 Friday 3
3 18/01/2018 4 Thursday 4
4 17/01/2018 10 Wednesday 10
5 16/01/2018 2 Tuesday 2
6 15/01/2018 6 Monday 6
7 14/01/2018 1 Sunday 1
8 13/01/2018 9 Saturday 4
9 12/01/2018 9 Friday 3
10 11/01/2018 7 Thursday 4
11 10/01/2018 8 Wednesday 10
12 9/01/2018 6 Tuesday 2
13 8/01/2018 10 Monday 6
14 7/01/2018 6 Sunday 1
15 6/01/2018 3 Saturday 4
16 5/01/2018 3 Friday 3
17 4/01/2018 10 Thursday 4
18 3/01/2018 4 Wednesday 10
19 2/01/2018 2 Tuesday 2
20 1/01/2018 8 Monday 6
或者:
@Echo Off
Ping www.google.nl -n 1 -w 1000 >Nul 2>&1
If ErrorLevel 1 Exit /B
Echo hi
Pause