本文介绍 django.db.models.functions.Substr
的用法。
声明
class Substr(expression, pos, length=None, **extra)
从位置 pos
开始的字段或表达式返回长度为 length
的子字符串。该位置是 1 索引的,因此该位置必须大于 0。如果 length
是 None
,则将返回字符串的其余部分。
使用示例:
>>> # Set the alias to the first 5 characters of the name as lowercase
>>> from django.db.models.functions import Lower, Substr
>>> Author.objects.create(name='Margaret Smith')
>>> Author.objects.update(alias=Lower(Substr('name', 1, 5)))
1
>>> print(Author.objects.get(name='Margaret Smith').alias)
marga
相关用法
- Python Sympy Subset.rank_lexicographic()用法及代码示例
- Python Sympy Subset.next_lexicographic()用法及代码示例
- Python Sympy Subset.iterate_graycode()用法及代码示例
- Python Sympy Subset.unrank_binary()用法及代码示例
- Python Sympy Subset.cardinality()用法及代码示例
- Python Sympy Subset.prev_gray()用法及代码示例
- Python Sympy Subset.ksubsets()用法及代码示例
- Python Sympy Subset.subset()用法及代码示例
- Python Sympy Subset.next_gray()用法及代码示例
- Python Sympy Subset.subset_indices()用法及代码示例
- Python Sympy Subset.rank_binary()用法及代码示例
- Python Sympy Subset.next_binary()用法及代码示例
- Python Sympy Subset.prev_lexicographic()用法及代码示例
- Python Sympy Subset.unrank_gray()用法及代码示例
- Python Sympy Subset.superset_size()用法及代码示例
- Python Sympy Subset.superset()用法及代码示例
- Python Sympy Subset.iterate_binary()用法及代码示例
- Python Sympy Subset.rank_gray()用法及代码示例
- Python Sympy Subset.prev_binary()用法及代码示例
- Python Sympy Subset.size()用法及代码示例
- Python Sympy Subset.subset_from_bitlist()用法及代码示例
- Python Sympy Subset.bitlist_from_subset()用法及代码示例
- Python Django SuccessMessageMixin用法及代码示例
- Python Scipy integrate.quadrature()用法及代码示例
- Python Scipy stats.hypsecant.moment()用法及代码示例
注:本文由纯净天空筛选整理自djangoproject.com大神的英文原创作品 django.db.models.functions.Substr。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。