Every line of 'python split string into dictionary' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
126 def split_string(input_string): 127 '''Split a string to a list and strip it 128 :param input_string: A string that contains semicolons as separators. 129 ''' 130 string_splitted = input_string.split(';') 131 # Remove whitespace at the beginning and end of each string 132 strings_striped = [string.strip() for string in string_splitted] 133 return strings_striped
53 def _string_to_dict(s): 54 return {name: value for (name, value) in (v.split('=') for v in s.split(' ') if v)}
34 def stringToDict(items=None): 35 """ 36 Return a correct dict from a string 37 """ 38 items = items.split('\r\n') 39 returnitems = [] 40 41 for item in items: 42 if item: 43 showinfo = [] 44 for x in item.split('='): 45 if x[-1:] == ' ': 46 x = x[:-1] 47 elif x[:1] == ' ': 48 x = x[1:] 49 showinfo.append(x) 50 showinfo = tuple(showinfo) 51 returnitems.append(showinfo) 52 returnitems = dict(returnitems) 53 return returnitems
86 def tokenise_string(string): 87 """ 88 Splits the passed string into a list of strings, delimited by a space character 89 """ 90 return string.split()
286 def _split_list(value): 287 """Split a string list into parts.""" 288 if value: 289 return [p for p in LIST_SEP_RE.split(value) if p] 290 else: 291 return []
476 def _split(self, string): 477 start_index, max_index = self._find_variable(string) 478 self.start = start_index 479 self._open_curly = 1 480 self._state = self._variable_state 481 self._variable_chars = [string[start_index], '{'] 482 self._list_variable_index_chars = [] 483 self._string = string 484 start_index += 2 485 for index, char in enumerate(string[start_index:]): 486 index += start_index # Giving start to enumerate only in Py 2.6+ 487 try: 488 self._state(char, index) 489 except StopIteration: 490 return 491 if index == max_index and not self._scanning_list_variable_index(): 492 return
6 def split_words(d): 7 return [x.split() for x in d.splitlines()]
143 def _split_basic(string): 144 """ 145 Split a string into a list of tuples of the form (key, modifier_fn, 146 explode) where modifier_fn is a function that applies the appropriate 147 modification to the variable. 148 """ 149 tuples = [] 150 for word in string.split(','): 151 # Attempt to split on colon 152 parts = word.split(':', 2) 153 key, modifier_fn, explode = parts[0], _identity, False 154 if len(parts) > 1: 155 modifier_fn = functools.partial( 156 _truncate, num_chars=int(parts[1])) 157 if word[len(word) - 1] == '*': 158 key = word[:len(word) - 1] 159 explode = True 160 tuples.append((key, modifier_fn, explode)) 161 return tuples
102 def mkdict(s): 103 xdict = {} 104 if isinstance(s, str): 105 s = s.split() 106 for kvstr in s: 107 k,v = kvstr.split('=') 108 xdict[k] = v 109 return xdict