所以我将Play框架与Docker一起使用(特别是使用此图像),并尝试启动并运行服务器.
干
$ sudo docker-compose run web activator run
Run Code Online (Sandbox Code Playgroud)
按预期工作:网络服务器启动并保持接受传入请求.
但后来我试试
$ sudo docker-compose up -d
Run Code Online (Sandbox Code Playgroud)
和
$ sudo docker-compose logs
...
web_1 | [info] [SUCCESSFUL ] org.ow2.asm#asm-analysis;4.1!asm-analysis.jar (16ms)
web_1 | [info] downloading file:/activator-1.3.2/repository/org.ow2.asm/asm-util/4.1/jars/asm-util.jar ...
web_1 | [info] [SUCCESSFUL ] org.ow2.asm#asm-util;4.1!asm-util.jar (32ms)
web_1 | [info] Done updating.
web_1 |
web_1 | --- (Running the application from SBT, auto-reloading is enabled) ---
web_1 |
web_1 | [info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
web_1 |
web_1 | (Server …Run Code Online (Sandbox Code Playgroud) 我的代码是这样的:
public class Foo {
public int a;
Bar[] bar = new Bar[10];
a = bar[0].baz;
}
public class Bar {
public int b;
public Bar () { //I tried doing away with this constructor, but that didn't
//fix anything
b = 0;
}
public int Baz () {
//do somthing
}
}
Run Code Online (Sandbox Code Playgroud)
我收到类似于的错误消息:
Exception in thread "Foo" java.lang.NullPointerException
Run Code Online (Sandbox Code Playgroud)
在Foo中的哪一行,我尝试调用类Bar的任何函数或值.如何防止bar []为空?
编辑:经过一番摆弄,我终于把它修好了,谢谢大家!但是,我无法调用构造函数来解决问题; 我必须创建另一个函数并从Main调用该函数(在我的例子中,类Foo实际上是Main类,如果真的很重要).我的最终结果:
public class Foo {
public int a;
Bar[] bar = new Bar[10];
public Foo () { //this …Run Code Online (Sandbox Code Playgroud) 我在Python中有这个代码
inputted = input("Enter in something: ")
print("Input is {0}, including the return".format(inputted))
Run Code Online (Sandbox Code Playgroud)
那个输出
Enter in something: something
Input is something
, including the return
Run Code Online (Sandbox Code Playgroud)
我不确定发生了什么; 如果我使用不依赖于用户输入的变量,我在使用变量格式化后不会获得换行符.我怀疑当我点击返回时,Python可能会将换行符作为输入.
我怎样才能使输入不包含任何换行符,以便我可以将它与其他字符串/字符进行比较?(例如something == 'a')
我收到
TypeError: Can't convert 'float' object to str implicitly
Run Code Online (Sandbox Code Playgroud)
使用时
Gambler.pot += round(self.bet + self.money * 0.1)
Run Code Online (Sandbox Code Playgroud)
锅,赌注和金钱都是双打(或至少应该是).我不确定这是否是另一个Eclipse的东西,但我如何让这行编译?
代码在何处bet和money初始化:
class Gambler:
money = 0
bet = 0
Run Code Online (Sandbox Code Playgroud)
测试用例:
number = 0
print("Here, the number is a {0}".format(type(number)))
number = input("Enter in something: ")
print("But now, it has turned into a {0}".format(type(number)))
Run Code Online (Sandbox Code Playgroud)
测试用例的输出:
Here, the number is a <class 'int'>
Enter in something: 1
But now, it has turned into a <class 'str'>
Run Code Online (Sandbox Code Playgroud)
显然,input()正在将其更改为字符串.
编辑:最后解决了问题(我认为)
self.bet …Run Code Online (Sandbox Code Playgroud) 如果我只想检查某些东西是否不可能(即,我不会使用类似的东西if(possible)),我应该命名布尔值notPossible并使用if(notPossible)或者我应该命名它possible并使用if(!possible)吗?
而只是可以肯定,如果我也有检查其是否是possible,我会说出布尔可能和使用if(possible)以及else,对不对?
假设我有一个Animal类Cow继承的基类,以及一个Barn包含Animal向量的类,让我们假设Animal类有一个虚函数scream(),它Cow会覆盖.
使用以下代码:
Animal.h
#ifndef _ANIMAL_H
#define _ANIMAL_H
#include <iostream>
using namespace std;
class Animal {
public:
Animal() {};
virtual void scream() {cout << "aaaAAAAAAAAAAGHHHHHHHHHH!!! ahhh..." << endl;}
};
#endif /* _ANIMAL_H */
Run Code Online (Sandbox Code Playgroud)
Cow.h
#ifndef _COW_H
#define _COW_H
#include "Animal.h"
class Cow: public Animal {
public:
Cow() {}
void scream() {cout << "MOOooooOOOOOOOO!!!" << endl;}
};
#endif /* _COW_H */
Run Code Online (Sandbox Code Playgroud)
Barn.h
#ifndef _BARN_H
#define _BARN_H
#include "Animal.h"
#include <vector> …Run Code Online (Sandbox Code Playgroud) 目前,一个项目中的链接器在链接到另一个项目中的源文件生成的目标文件时出现问题.有没有办法手动将这些目标文件添加到Qt?
有没有办法在Mathematica中获得数字的数量级?例如200将具有2的数量级.
我写了一个C++程序(有一个main.cpp,各种标题和实现文件),可以在g ++下编译.现在我试图在Cern的ROOT库中编译它,但我不知道如何,因为我知道如何在ROOT中编译文件的唯一方法是使用.L main.cpp.
如何在ROOT中包含多个文件?
c++ ×3
python ×2
boolean ×1
compilation ×1
docker ×1
inheritance ×1
input ×1
java ×1
linker ×1
map ×1
naming ×1
newline ×1
null ×1
object-files ×1
python-3.x ×1
qt ×1
stl ×1
string ×1
swap ×1
user-input ×1