Skip to content Skip to sidebar Skip to footer

String Storage In Python Class Includes Newline Character

I have an output class that looks like the following (somewhat redacted): from colorclass import Color from colorclass import disable_all_colors, enable_all_colors, is_enabled from

Solution 1:

You are not showing us how you read the domains, but using:

for domain in domainFileDescriptor:
     domains.append(domain)

#or
domains=domainFileDescriptor.readlines()

will conserve the newline at the end of every line read from the file. You need to strip them:

for domain in domainFileDescriptor:
     domains.append(domain.strip())

The hint is the placement of the newline (right after the domain). Note: a file descriptor and handle is the same thing in this context.

Post a Comment for "String Storage In Python Class Includes Newline Character"