Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
int list have no len()
#3
(Mar-21-2019, 02:06 PM)lateublegende Wrote: I try to write my list, but I need len() for write it.
if I write in str, they print 5 item.
Most be str to write paramiko doc.
Example if have list with integers,need to convent fourth and back to original list.
lst = [1, 2, 3 ,4]
# Most be string befor write
lst = ','.join(str(i) for i in lst)
with open('test.dat', 'w') as f:
    f.write(lst)

with open('test.dat') as f:
    lst = f.read().split(',')
    lst = [int(i) for i in lst]
    print(lst)
Output:
[1, 2, 3, 4]
Reply


Messages In This Thread
int list have no len() - by lateublegende - Mar-21-2019, 02:06 PM
RE: int list have no len() - by ichabod801 - Mar-21-2019, 02:38 PM
RE: int list have no len() - by snippsat - Mar-21-2019, 09:10 PM

Forum Jump:

User Panel Messages

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