Python Forum
Writing list as a file, then reading that file as a list
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Writing list as a file, then reading that file as a list
#2
(Oct-16-2019, 08:52 PM)Zoastria_Balnala Wrote: I want each number between the commas to be a separate entry.

contents.split(',') should split it by the comma. Not sure if there is a faster way since its a long string.

>>> s = '1.7130853299339677, 1.7130853299339677, 1.7130853299339677, 1.7130853299339677, 1.7130853299339677'
>>> s.split(',')
['1.7130853299339677', ' 1.7130853299339677', ' 1.7130853299339677', ' 1.7130853299339677', ' 1.7130853299339677']
Recommended Tutorials:
Reply


Messages In This Thread
RE: Writing list as a file, then reading that file as a list - by metulburr - Oct-16-2019, 09:24 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Strange behavior list of list mmhmjanssen 3 347 May-09-2024, 11:32 AM
Last Post: mmhmjanssen
  file open "file not found error" shanoger 8 1,272 Dec-14-2023, 08:03 AM
Last Post: shanoger
Sad problems with reading csv file. MassiJames 3 713 Nov-16-2023, 03:41 PM
Last Post: snippsat
  Search Excel File with a list of values huzzug 4 1,312 Nov-03-2023, 05:35 PM
Last Post: huzzug
  trouble reading string/module from excel as a list popular_dog 0 455 Oct-04-2023, 01:07 PM
Last Post: popular_dog
  No matter what I do I get back "List indices must be integers or slices, not list" Radical 4 1,275 Sep-24-2023, 05:03 AM
Last Post: deanhystad
  Need to replace a string with a file (HTML file) tester_V 1 800 Aug-30-2023, 03:42 AM
Last Post: Larz60+
  Reading a file name fron a folder on my desktop Fiona 4 988 Aug-23-2023, 11:11 AM
Last Post: Axel_Erfurt
  How can I change the uuid name of a file to his original file? MaddoxMB 2 991 Jul-17-2023, 10:15 PM
Last Post: Pedroski55
  Delete strings from a list to create a new only number list Dvdscot 8 1,608 May-01-2023, 09:06 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020