将Numpy数组连接到Numpy数组数组

时间:2015-12-08 23:39:42

标签: python arrays numpy

我正在尝试创建一个for循环,每次添加一个数组,到数组数组的末尾,我不能完全指责如何。 该计划的总体思路:

//$serverStatus = 1 means servers up, 0 means down, 3 means crashed
$timeout = new-timespan -Seconds 280
$sw = [diagnostics.stopwatch]::StartNew()
while ($sw.elapsed -lt $timeout){
    Start-Sleep -Seconds 10

    if (((get-process $process -ea SilentlyContinue) -eq $Null) -And ($serverStatus -eq "1")) {
        #Server is down and email
        "0" > "D:\Ark Scripts\serverStatus.txt"
        Write-Host "it's down - email"
        sendMail -sendTo "my email" -emailBody "Ark Server is down."

    } elseif (((get-process $process -ea SilentlyContinue) -eq $Null) -And ($serverStatus -eq "0")) {
        #Server is down and we are aware
        Write-Host "it's down - we know"
    } elseIf (((get-process $process -ea SilentlyContinue) -ne $Null) -And ($serverStatus -eq "0")) {
        #Server is up and email
        "1" > "D:\Ark Scripts\serverStatus.txt"
        Write-Host "it's up - email"
        sendMail -sendTo "my email" -emailBody "Ark Server is back up."
    } elseif ($serverStatus -eq "3") {
        Send-RCON "listplayers" > "D:\Ark Scripts\RCONlog.txt"

        $log = Get-Content "D:\Ark Scripts\RCONlog.txt"

        if ($log -eq "Authentication failed!") {
            Write-Host "crashed and we know"
        } else {
           "1" > "D:\Ark Scripts\serverStatus.txt"
           Write-Host "Back up"
        }
    } else {
        #Checks RCON connection for crashes and sends crash email if connection fails.
        Send-RCON "listplayers" > "D:\Ark Scripts\RCONlog.txt"

        $log = Get-Content "D:\Ark Scripts\RCONlog.txt"

        if ($log -eq "Authentication failed!") {
            Write-Host "crashed"
            "3" > "D:\Ark Scripts\serverStatus.txt"
            sendMail -sendTo "my email" -emailBody "Ark Server has crashed."
            return
        } else {
            "1" > "D:\Ark Scripts\serverStatus.txt"
            Write-Host "it's up"
        }
    }
}

Exit-PSSession

例如,输出:

for x in range(0,longnumber):
    generatenewarray
    add new array to end of array

将是:newArray = [1,2,3] array = [[1,2,3,4],[1,4,3]]

如果措辞不好让我知道,我可以尝试编辑它以便更好!

2 个答案:

答案 0 :(得分:1)

这是你需要的吗?

list_of_arrays = []
for x in range(0,longnumber):
    a = generatenewarray
    list_of_arrays.append(a)

答案 1 :(得分:0)

它不漂亮,但这会奏效。你将两个numpy数组转换成列表,添加这两个列表,最后将结果转换为一个新的numpy数组:

np.array(array.tolist() + newArray.tolist())