小编pet*_*huk的帖子

如果变量不是 None 并且大于一行中的某个值,如何在 python 中检查?

如何在一行中做出这个声明?

if x is not None:
    if x > 0:
        pass
Run Code Online (Sandbox Code Playgroud)

如果我只用“和”写,如果没有,它会显示异常

if x is not None and x > 0:
     pass
Run Code Online (Sandbox Code Playgroud)

python python-2.7

2
推荐指数
1
解决办法
9170
查看次数

如何使用构造函数中的参数来调用C++中另一个类的构造函数?

我有个问题.我想从"Game"类中调用"gameWindow"的构造函数.问题是,如果我从构造函数中调用它,它将初始化为局部变量(示例A),如果我将其定义为私有成员 - 我不能使用构造函数的参数.如何将gamewindowObj作为构造函数的成员?

//示例А

class Game{
public:
    Game(int inWidth, int inHeight, char const * Intitle);
};

Game::Game(int inWidth, int inHeight, char const * Intitle){
    gameWindow gamewindowObj=gameWindow(inWidth, inHeight, Intitle);
}
Run Code Online (Sandbox Code Playgroud)

//示例В

class Game{
public:
    Game(int inWidth, int inHeight, char const * Intitle);
private:
    gameWindow gamewindowObj=gameWindow(inWidth, inHeight, Intitle);
};
Game::Game(int inWidth, int inHeight, char const * Intitle){}
Run Code Online (Sandbox Code Playgroud)

c++ oop constructor initialization

1
推荐指数
1
解决办法
68
查看次数

如何在virtualenv中强制安装软件包?

尝试在系统中安装具有不同版本的django,它向我显示:

Installing collected packages: Django
Found existing installation: Django 1.7.11
Not uninstalling django at /home/user/lib/python2.7, outside environment /home/user/webapps/v2_dev/venv
Run Code Online (Sandbox Code Playgroud)

成功安装Django-1.8.19

但实际上有旧版本

尝试了不同的命令:

./venv/bin/pip install Django==1.8.11

pip install Django==1.8.11
Run Code Online (Sandbox Code Playgroud)

更新:安装软件包时,它显示:

The required version of setuptools (>=16.0) is not available,
and can't be installed while this script is running. Please
install a more recent version first, using
'easy_install -U setuptools'.
(Currently using setuptools 3.1 (/home/user/lib/python2.7/setuptools-3.1-py2.7.egg))
Run Code Online (Sandbox Code Playgroud)

升级时:

venv/bin/pip install --upgrade setuptools
Requirement already up-to-date: setuptools in ./venv/lib/python2.7/site-packages (40.5.0)
Run Code Online (Sandbox Code Playgroud)

python django pip webfaction

1
推荐指数
3
解决办法
2328
查看次数

标签 统计

python ×2

c++ ×1

constructor ×1

django ×1

initialization ×1

oop ×1

pip ×1

python-2.7 ×1

webfaction ×1