我想连接空的 3d numpy 数组
#2d array works
xs = np.array([[1,2,3,4,5],[10,20,30,40,50]])
ys = np.array([]).reshape(0,5)
zs = np.vstack([ys, xs])
#3D does not work
bb = np.array([]).reshape(1080, 1920, 0) # empty
ss = np.random.rand(1080, 1920,2) #
dd = np.vstack([bb, ss]) # generate an error
Run Code Online (Sandbox Code Playgroud)
有可能做到吗?
这里有一个例子:
a = np.array([[1, 2, 3,4], [], [1,2,0,9]])
print(a)
# array([list([1, 2, 3, 4]), list([]), list([1, 2, 0, 9])], dtype=object)
Run Code Online (Sandbox Code Playgroud)
如何删除空元素并仅返回:
array([[1, 2, 3, 4], [1, 2, 0, 9]], dtype=object)
Run Code Online (Sandbox Code Playgroud) 我是Qt的c ++编程新手.我做两个班Personnage和Arme.我有5个文件Personnage.h,personnage.cpp,Arme.h和Arme.cpp
Arme.h
#ifndef ARME_H
#define ARME_H
#include<iostream>
class Arme
{
public:
Arme();
Arme(int m_idArme,std::string m_nomArme);
void armeAffich() const;
public:
int idArme;
std::string nomArme;
};
#endif // ARME_H
Run Code Online (Sandbox Code Playgroud)
Arme.cpp
#include "Arme.h"
#include<string>
#include<iostream>
using namespace std;
Arme::Arme():idArme(0),nomArme(0)
{
}
Arme::Arme(int m_idArme,string m_nomArme)
{
idArme=m_idArme;
nomArme=m_nomArme;
}
void Arme::armeAffich() const
{
cout<<"identifiant d'arme"<<idArme<<endl;
cout<<"nom d'arme"<<nomArme<<endl;
}
Run Code Online (Sandbox Code Playgroud)
Personnage.h
#ifndef PERSONNAGE_H
#define PERSONNAGE_H
#include "Arme.h"
class Personnage
{
Personnage(std::string nom,std::string prenom);
Personnage();
~Personnage();
void affichPers() const;
public:
std::string nomPers;
std::string prenomPers;
Arme *arme; …Run Code Online (Sandbox Code Playgroud) 我想用cout在c ++中打印一条大消息.
例:
cout<<"Camera could not be opened in the requested access mode, because another
application (possibly on another host) is using the camera."<<endl;
Run Code Online (Sandbox Code Playgroud)
但是我收到了一个错误.
任何帮助?