小编Zah*_*and的帖子

在像Eclipse这样的标签中有多个项目?[的IntelliJ]

所以我在做了一些研究后才从Eclipse转移到IntelliJ.我唯一想念的是,在Eclipse中,我可以在不同的选项卡中拥有多个项目,并轻松地比较项目.但是在IntelliJ中我必须在新窗口中打开一个项目.难道不可能像eclipse一样在工具窗口中拥有所有项目吗?

eclipse intellij-idea

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

Python TypeError:/:'NoneType'和'float'不支持的操作数类型

这是我们老师的一项任务.我们应该使用Simpson的规则来对函数进行数值积分f(x) = x*cos(third_root(x))

但我们不允许使用内置函数cos或用于x**(1.0/3.0)查找第三个根.

我得到错误:

Traceback (most recent call last):
  File "path", line 104, in <module>
    print simpson(f, 1.0, 50.0, 10)
  File "path", line 91, in simpson
    I += 2 * f(x) + (4.0 * f(x + h))
  File "path", line 101, in f
     return x*final_cos(final_3root(x))
  File "path", line 72, in final_cos
    x = float_mod(x, 2 * pi)
  File "path", line 42, in float_mod
    k = int(x / a)
TypeError: unsupported operand type(s) for /: …
Run Code Online (Sandbox Code Playgroud)

python typeerror

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

简化陈述

我正在研究一个项目,我正在使用Intellij IDEA.在我写作的时候,我收到了一条通知,说明我的if语句可以简化了.(注意我还是新编码)

它说:

报告if语句可以简化为单个赋值还是返回语句.例如:

if (foo()) {
   return true;
} else {
   return false;
}
Run Code Online (Sandbox Code Playgroud)

可以简化为

return foo();
Run Code Online (Sandbox Code Playgroud)

这是如何运作的?假设foo()是数字4,这不会只返回4而不是真的吗?我有什么误会?

编辑

这是我写的代码:

if (row > 0 && row < 4 && col > 0 && col < 4) {
    return false;
} else {
    return true;
}
Run Code Online (Sandbox Code Playgroud)

它可以简化为:

return !(row > 0 && row < 4 && col > 0 && col < 4);
Run Code Online (Sandbox Code Playgroud)

我只是不明白这是如何简化的.

java intellij-idea simplify

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

函数返回每个二进制数直到某个值

我有这个功能:

def binary_numbers(a):
    for x in range(1, a):
        return bin(x)
Run Code Online (Sandbox Code Playgroud)

我希望这个打印从0 my_input到此命令的每个二进制数.

print binary_numbers(my_input)
Run Code Online (Sandbox Code Playgroud)

所以,如果我写5作为参数,我希望它打印

0b0
0b1
0b10
0b11
0b100
0b101
Run Code Online (Sandbox Code Playgroud)

但是,当我用5调用它时,我得到的是:

>>> print binary_numbers(5)
'0b1'
Run Code Online (Sandbox Code Playgroud)

谁能解释我为什么?

python

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

标签 统计

intellij-idea ×2

python ×2

eclipse ×1

java ×1

simplify ×1

typeerror ×1