Home > other > The Python string set all the substring
The Python string set all the substring
Time:09-22
For all the substring of string sets, such as "ABC" substring 'a', 'b', 'c', 'ab', "BC", "ABC", now have the idea is to traverse all string length according to the position control, to write again after heavy list, but if the string through long, number too much, many cycles, the program runs, hope everybody can big door to give some advice, thank you
CodePudding user response:
Is there a man
CodePudding user response:
#! The/usr/bin/env python # - * - coding: utf-8 - * - # Python 3.6 The from itertools import the accumulate
Def all_sub_string (a_string) : If len (a_string)==1: Return [a_string] The else: Return the list (the accumulate (a_string)) + all_sub_string (a_string [1])