Hey guys is there anyway to ask for user input and turn their input into a list, tuple, or string for that matter? I want a series of numbers to insert into a matrix. I could tell them to type all the numbers into the console with no spaces and iterate through them but are there any other ways to do this?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
NumPy supports MATLAB-style matrix definitions if you're using it:
e.g.
sets the
matrix
to:Separate entries on each row by spaces and rows by semicolons.
if you want to have a list that automatically places a comma whenever it finds a space between numbers use this:
*split() will split them with commas, without input
*eg. 1 2 3 4 5 = [1, 2, 3, 4, 5]
You can simply do as follows: