本文整理汇总了Python中jmespath.compat.string_type方法的典型用法代码示例。如果您正苦于以下问题:Python compat.string_type方法的具体用法?Python compat.string_type怎么用?Python compat.string_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jmespath.compat
的用法示例。
在下文中一共展示了compat.string_type方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _func_to_string
# 需要导入模块: from jmespath import compat [as 别名]
# 或者: from jmespath.compat import string_type [as 别名]
def _func_to_string(self, arg):
if isinstance(arg, STRING_TYPE):
return arg
else:
return json.dumps(arg, separators=(',', ':'),
default=str)
示例2: _func_reverse
# 需要导入模块: from jmespath import compat [as 别名]
# 或者: from jmespath.compat import string_type [as 别名]
def _func_reverse(self, arg):
if isinstance(arg, STRING_TYPE):
return arg[::-1]
else:
return list(reversed(arg))
示例3: _func_type
# 需要导入模块: from jmespath import compat [as 别名]
# 或者: from jmespath.compat import string_type [as 别名]
def _func_type(self, arg):
if isinstance(arg, STRING_TYPE):
return "string"
elif isinstance(arg, bool):
return "boolean"
elif isinstance(arg, list):
return "array"
elif isinstance(arg, dict):
return "object"
elif isinstance(arg, (float, int)):
return "number"
elif arg is None:
return "null"
示例4: _is_comparable
# 需要导入模块: from jmespath import compat [as 别名]
# 或者: from jmespath.compat import string_type [as 别名]
def _is_comparable(x):
# The spec doesn't officially support string types yet,
# but enough people are relying on this behavior that
# it's been added back. This should eventually become
# part of the official spec.
return _is_actual_number(x) or isinstance(x, string_type)