Python put file in array




















Connect and share knowledge within a single location that is structured and easy to search. Alternatively, the more straightforward method, using f. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams?

Collectives on Stack Overflow. Learn more. Reading a file line by line into elements of an array in Python [duplicate] Ask Question. Asked 8 years, 8 months ago. Active 8 years, 8 months ago. Viewed k times.

TigerhawkT3 Rasheed Billy Rasheed Billy 35 1 1 silver badge 2 2 bronze badges. What do you expect your output array to look like? Could it be that you actually want to split the strings? Are you using numpy? If not, do you mean a list instead of an array? Add a comment. Active Oldest Votes. TigerhawkT3 TigerhawkT3 Note the print statement. This is irrelevant. Thank you for your input. Show 1 more comment. CDspace 2, 17 17 gold badges 32 32 silver badges 36 36 bronze badges.

Karim B Karim B 54 9 9 bronze badges. Samruddhi Chitnis Samruddhi Chitnis 41 5 5 bronze badges. You are missing the split step. Check the question more carefully. Some questions come to mind about what the rest of your implementation looks like and how you figure it all will work, but below is an example of how this could be done in a pretty straight forward way:.

So even if this works, it might be a good idea to think about the format of the text file if you have control of that , and see if it can be changed into something which would allow you to use some parsing library in a simple way, e. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 6 years, 2 months ago.

Active 6 years, 2 months ago. Viewed times. Ciaran Ciaran 1 1 gold badge 12 12 silver badges 32 32 bronze badges. ARe r , w and s defined in your code somewhere? If they aren't you are going to have to leave them as strings.



0コメント

  • 1000 / 1000