About 79,400 results
Open links in new tab
  1. Python - convert a string to an array - Stack Overflow

    Apr 25, 2018 · If you mean using the Python array module, then you could do like this: import array as ar x = ar.array('c') # Character array for i in ['Foo', 'Bar', 'Baz', 'Woo']: x.extend(ar.array('c', i)) print x #array('c', 'FooBarBazWoo')

  2. python - How do I split a string into a list of characters? - Stack ...

    If you just need an array of chars: arr = list(str) If you want to split the str by a particular delimiter: # str = "temp//temps" will will be ['temp', 'temps'] arr = str.split("//")

  3. Convert String to Array in Python - Python Guides

    Apr 14, 2025 · 4. Use array Module. The array module in Python creates compact, efficient arrays of basic data types. Unlike lists which can hold mixed data types, arrays from this module can only store items of a single type.. import array # Our original string my_string = "Hello" # Converting string to an array of characters using array module # 'u' type code represents Unicode character my_array = array ...

  4. python - Extract array from string - Stack Overflow

    Try eval() function of python. >>> arr=eval("[[[234],[432],[523]]]") >>> arr [[[234], [432], [523]]]

  5. Python String to Array – How to Convert Text to a List

    Feb 21, 2022 · In this article, you'll see a few of the ways in which you can convert a string to a list. Here is what we will cover: What are Strings and Lists in Python? A string is an ordered sequence of characters. It is a series of characters, with one character following the other. A string is surrounded by either single or double quotation marks:

  6. Python String to Array – How to Convert Text to a List

    Sep 3, 2024 · This guide covered practical applications, best practices, performance factors and advanced functionality for converting Python strings to lists or arrays. The key options in the core library are list() for basic string separation and split() for delimiter-based substrings.

  7. Convert Python String To Array: Methods & Best Practices

    Learn different methods to convert a Python string to an array, common errors to avoid, and best practices for handling empty strings and whitespace. When it comes to converting a string into an array in Python, the split() method is a handy tool to have in your arsenal.

  8. How To Convert Python String To Array - pythonpip.com

    Dec 13, 2020 · We’ll convert String to array in Python. The python string package has split() method. The String.split() method splits the String from the delimiter and returns it as a list item.

  9. How To Convert Python String To Array - ItsMyCode

    Oct 15, 2024 · If you want to convert a string to an array of characters, you can use the list() method, an inbuilt function in Python. Note: If the string contains whitespace, it will be treated as characters, and whitespace also will be converted to a list.

  10. Python Split String – How to Split a String into a List or Array in ...

    Dec 22, 2024 · In this comprehensive guide, you‘ll learn different options for splitting strings into lists or arrays in Python. We‘ll cover key methods like split(), partition(), splitlines(), and regular expressions.

  11. Some results have been removed
Refresh