【问题标题】:Julia not operator朱莉娅不是运算符
【发布时间】:2021-04-05 20:32:54
【问题描述】:

我想知道是否有办法使用诸如ismissing()isempty() 等函数的非运算符 例如,如果我想做这样的事情,我该怎么做。

x = Array[]
y = missing

if x not isempty(x)
    # do something
elif not ismissing(y)
    # do something
end

这当然是不正确的,空数组可以用if length(x) >0解决。但我想知道是否有一种方法可以像在 python 中那样使用非运算符。例如,在 python numpy 库中,我可以做这样的事情来实现这一点,

y = np.nan
if y is not np.nan:
    #do something

【问题讨论】:

    标签: julia


    【解决方案1】:

    这是!(x) 函数,例如!ismissing(x).

    【讨论】:

      猜你喜欢
      • 2018-11-27
      • 2014-04-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-04
      • 2014-12-31
      • 2017-01-15
      相关资源
      最近更新 更多