diff --git a/docs/user_docs/support/faq-kcl.md b/docs/user_docs/support/faq-kcl.md index eec6157c..3716acb0 100644 --- a/docs/user_docs/support/faq-kcl.md +++ b/docs/user_docs/support/faq-kcl.md @@ -482,6 +482,16 @@ isEmptyList = bool(_emptyList) isEmptyDict = bool(_emptyDict) ``` +In addition, if we want to determine that a variable is only `None`/`Undefined` and not empty, we can use the following expression or the built-in function `isnullish()` + +```python +a = None +_emptyList = [] +isEmptyList = bool(_emptyList) +isNullishList1 = _emptyList not in [None, Undefined] +isNullishList2 = isnullish(_emptyList) +``` + ## 12. How to concatenate strings, format strings, check string prefixes and suffixes and replace string content? - The `+` operator can be used to concatenate two strings in KCL diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/user_docs/support/faq-kcl.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/user_docs/support/faq-kcl.md index 4f5ff078..4d6ec522 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/user_docs/support/faq-kcl.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/user_docs/support/faq-kcl.md @@ -484,6 +484,16 @@ isEmptyList = bool(_emptyList) isEmptyDict = bool(_emptyDict) ``` +此外,如果我们想要判断一个变量仅为 `None`/`Undefined`,而不为空,则可以使用下面的表达式或者 `isnullish()` 内置函数 + +```python +a = None +_emptyList = [] +isEmptyList = bool(_emptyList) +isNullishList1 = _emptyList not in [None, Undefined] +isNullishList2 = isnullish(_emptyList) +``` + ## 12. 字符串怎样拼接、怎样格式化字符串、怎样检查字符串前缀、后缀?怎样替换字符串内容? - KCL 中可以使用 `+` 运算符连接两个字符串 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.10/user_docs/support/faq-kcl.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.10/user_docs/support/faq-kcl.md index 4f5ff078..4d6ec522 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.10/user_docs/support/faq-kcl.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-0.10/user_docs/support/faq-kcl.md @@ -484,6 +484,16 @@ isEmptyList = bool(_emptyList) isEmptyDict = bool(_emptyDict) ``` +此外,如果我们想要判断一个变量仅为 `None`/`Undefined`,而不为空,则可以使用下面的表达式或者 `isnullish()` 内置函数 + +```python +a = None +_emptyList = [] +isEmptyList = bool(_emptyList) +isNullishList1 = _emptyList not in [None, Undefined] +isNullishList2 = isnullish(_emptyList) +``` + ## 12. 字符串怎样拼接、怎样格式化字符串、怎样检查字符串前缀、后缀?怎样替换字符串内容? - KCL 中可以使用 `+` 运算符连接两个字符串 diff --git a/versioned_docs/version-0.10/user_docs/support/faq-kcl.md b/versioned_docs/version-0.10/user_docs/support/faq-kcl.md index eec6157c..3716acb0 100644 --- a/versioned_docs/version-0.10/user_docs/support/faq-kcl.md +++ b/versioned_docs/version-0.10/user_docs/support/faq-kcl.md @@ -482,6 +482,16 @@ isEmptyList = bool(_emptyList) isEmptyDict = bool(_emptyDict) ``` +In addition, if we want to determine that a variable is only `None`/`Undefined` and not empty, we can use the following expression or the built-in function `isnullish()` + +```python +a = None +_emptyList = [] +isEmptyList = bool(_emptyList) +isNullishList1 = _emptyList not in [None, Undefined] +isNullishList2 = isnullish(_emptyList) +``` + ## 12. How to concatenate strings, format strings, check string prefixes and suffixes and replace string content? - The `+` operator can be used to concatenate two strings in KCL