Python Forum
Search & Replace - Newlines Added After Replace
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Search & Replace - Newlines Added After Replace
#1
Hi,

the below script works, but it adds a new line after it replaces

I cant understand why
it should just do a straight replace


with open('c:/Users/Dan/Desktop/Replace.txt') as f:            
    for l in f:
        #s = l.split()
        s = l.split('|')
        editor.replace(s[0], s[1])
Replace file
apple|pear
hello|Hi



:)


Python newbie trying to learn the ropes
Reply


Messages In This Thread
Search & Replace - Newlines Added After Replace - by dj99 - Jul-22-2018, 10:54 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  replace text in a txt cartonics 19 2,248 Jan-30-2024, 06:58 AM
Last Post: Athi
  Regex replace in SQLite3 database WJSwan 1 809 Dec-04-2023, 05:55 PM
Last Post: Larz60+
  Replace a text/word in docx file using Python Devan 4 3,467 Oct-17-2023, 06:03 PM
Last Post: Devan
  Python beginner that needs an expression added to existing script markham 1 713 Sep-04-2023, 05:24 AM
Last Post: Pedroski55
  Need to replace a string with a file (HTML file) tester_V 1 776 Aug-30-2023, 03:42 AM
Last Post: Larz60+
  why doesn't it replace all html tags? Melcu54 3 762 Jul-05-2023, 04:47 AM
Last Post: Melcu54
  Replace string in a nested Dictianory. SpongeB0B 2 1,217 Mar-24-2023, 05:09 PM
Last Post: SpongeB0B
  Working with Excel and Word, Several Questions Regarding Find and Replace Brandon_Pickert 4 1,570 Feb-11-2023, 03:59 PM
Last Post: Brandon_Pickert
  Replace with upper(string) WJSwan 7 1,602 Feb-10-2023, 10:28 AM
Last Post: WJSwan
  Replace columns indexes reading a XSLX file Larry1888 2 996 Nov-18-2022, 10:16 PM
Last Post: Pedroski55

Forum Jump:

User Panel Messages

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