Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: UTF-8 -*-
- def split_string_with_step(my_string, step):
- """
- create list of strings by split a big one with step
- """
- if (
- not isinstance(my_string, str) or
- not isinstance(step, int)
- ):
- raise NotImplementedError
- pos = 0
- my_list = []
- for char in range((len(my_string)//step)+1):
- my_list.append(my_string[pos:pos+step])
- pos+=step
- if len(''.join(my_list)) == len(my_string):
- return my_list
- else:
- raise NotImplementedError
- # ~# example :
- my_string_test = """MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5qeHbZZQFLnXoiBrQb8udZxmz3FGnFFd63/qrlQ4GBpbf62DVMVEgZJOJFGEKW09KvgikBHtpRitYvW4g54s2/RVSK+6qpPq+Iw3jHuUrO3rkDW/2J5pcczUaxRQHuRyL9/fm7m9m4JMnFyTXV8Bn7hWrfH2VkVRz2wKd8BzBmMX1alCaVLLTz8NP2ccBO3U9Zyt4ZXPki5SOV3I421F9324y2VVtuqUewAGeYhGjcQ51yKlBggrkp+E1p9dmola7Xw6/UG3DIrgv88NeqAYiYjAfzMRwOjbQA2mhi770kINJKOWL59FbGcFxTcakzfdTljPHxWJy+u5aAoZNZQIDAQAB"""
- my_list_of_string = split_string_with_step(my_string_test, 6)
- for x in my_list_of_string:
- print(x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement