在我当前的django项目中,我有一个模型,它可以存储非常长的字符串(每个DB条目可以是5000-10000个甚至更多的字符),然后当用户调用记录时,我需要分割它们(它确实需要在DB中的一个记录中)。我需要的是返回一个列表(queryset?取决于是在“SQL”部分中还是按原样获取所有列表并在视图中进行解析)的较短字符串(我返回到模板的列表中,每个字符串100-500个字符)。在
我在任何地方都找不到python split命令、示例或任何类型的答案。。。。在
我总是能数单词和附加单词,但能数单词。。。。但我确信这类事情必须有某种功能。。。。在
编辑:谢谢大家,但我想我没有被理解Example:
The String: "This is a very long string with many many many many and many more sentences and there is not one character that i can use to split by, just by number of words"
字符串是django模型的textField。在
我需要把它分开,让我们说每一个5个单词,这样我就能得到:
['这是一个很长的字符串','有许多很多很多','还有更多的句子和','没有一个字符','我可以用','分裂,只是按数字','单词']The thing is that is almost every programming languages there is split per number of words" kind of utility function but i can't find one in python.
谢谢,
埃雷斯