本文整理匯總了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)