Every line of 'convert string list to int list python' 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.
80 def string_to_int_list(str): 81 if str is None: return [] 82 str = str.strip() 83 if str.find('-') != -1: 84 f = int(str[0:str.find('-')]) 85 t = int(str[str.find('-') + 1:]) 86 87 return range(f, t + 1) 88 elif str.startswith('['): 89 str = str[1:-1] 90 return [int(s) for s in str.split(', ')] 91 else: 92 elt = int(str) 93 return [elt]
119 def ToIntList(lst): 120 result = [] 121 if lst is None: 122 return result 123 if type(lst) == list: 124 for i in lst: 125 result.append(int(i)) 126 else: 127 split = lst.split( ) 128 for i in split: 129 result.append(int(i)) 130 return result
53 def toInts(inList): 54 outList = [] 55 for i in inList: 56 outList.append(int(i)) 57 return outList
420 def convert_list_str(string_list, type): 421 """ 422 Receive a string and then converts it into a list of selected type 423 """ 424 new_type_list = (string_list).split(",") 425 for inew_type_list, ele in enumerate(new_type_list): 426 if type is "int": 427 new_type_list[inew_type_list] = int(ele) 428 elif type is "float": 429 new_type_list[inew_type_list] = float(ele) 430 431 return new_type_list
64 def validate_list_of_integers(string): 65 # extract comma-separated list of integers 66 return list(map(int, string.split(',')))
1337 def ConvertToPythonStringList(to_convert): 1338 ''' 1339 Converts a python string list to a format more suitable for GUI representation 1340 @param to_convert:: The string list 1341 ''' 1342 return su.convert_to_string_list(to_convert)
74 def cast_tuple_int_list(tup): 75 """Set tuple float values to int for more predictable test results""" 76 return [int(a) for a in tup]
24 def convert_list_of_ints_to_string(array_of_ints): 25 return re.sub('\s+', ',', np.array_str(array_of_ints).strip('[]'))
10 def string_to_integer(string): 11 ''' 12 If the string isn't cataloged already, catalog it. 13 14 In any case, returns the number associated with the string. 15 ''' 16 global _catalog 17 if string in _catalog: 18 return _catalog.index(string) + 1 19 else: 20 _catalog.append(string) 21 return _catalog.index(string) + 1
81 def string2List(ustring): 82 """将ustring按照中文,字母,数字分开""" 83 retList = [] 84 utmp = [] 85 for uchar in ustring: 86 if is_other(uchar): 87 if len(utmp) == 0: 88 continue 89 else: 90 retList.append("".join(utmp)) 91 utmp = [] 92 else: 93 utmp.append(uchar) 94 if len(utmp) != 0: 95 retList.append("".join(utmp)) 96 return retList