ironpython - 字符串为空或空

标签 ironpython

好的,这里有一些简单的要点。 PyBinding带有以下脚本:

def IsNotNull(value):
    return value is not None

已经很近了,但是我想要的是这个。
bool IsNotNullOrEmpty(string value) {
    return (value != null) && (value.Length > 0 );
}

最佳答案

要检查字符串是否为空,可以使用 len 。试试这个:

def IsNotNull(value):
    return value is not None and len(value) > 0

关于ironpython - 字符串为空或空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2129713/

相关文章:

python - sqlite是否缓存查询结果以进行优化?

c# - IronPython 实现接口(interface)属性

silverlight - 用于在 Silverlight 中拖放的 TranslateTransform

python - 如何使用 Iron python 加载 DLL?

ironpython - 将 Spotfire 图形导出到 PowerPoint 的脚本

c# - 使用单声道从 C# 调用 IronPython 对象

c# - 将 IronPython 代码编译为 EXE 或 DLL

ironpython - 使用 IronPython 中的 PyQt

c# - 在 IronPython 中比较枚举值

c# - 如何将我的代码从 C# 转换为 Python?