Python Forum
It does truncatte where i would ...
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
It does truncatte where i would ...
#1
Hello !

I tried to do something that truncatte a list of strings but i doesn't truncate where i would to.

I show you what i would like:

(https://prnt.sc/qgww3f)
In the red rectangle is the thing i'd like to delete, but here what i have:

(https://prnt.sc/qgwwui)
How can I delete those ":" please ?

Here is the code:

import re

i = 0
fileString = input("Nom du fichier qui doit etre clean: ")
fileString = fileString.translate({ord('"'): None})
file = open(fileString, "r+")
logs = []
for line in file:
	if i < 4:
		i += 1
	else:
		logs.append(line[line.find(":"):])
file.seek(0)
file.truncate()
file.writelines(logs)
file.close()

Thank you for answering :) ♥
Reply


Messages In This Thread
It does truncatte where i would ... - by AyUniz - Dec-28-2019, 07:39 PM
RE: It does truncatte where i would ... - by AyUniz - Dec-28-2019, 10:24 PM

Forum Jump:

User Panel Messages

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