Python take the string of anything, ignoring all escape characters [closed]Convert JavaScript String to be all lower case?How do I parse a string to a float or int in Python?Python join: why is it string.join(list) instead of list.join(string)?Reverse a string in PythonConverting integer to string in Python?How to replace all occurrences of a string in JavaScriptDoes Python have a string 'contains' substring method?How can I print literal curly-brace characters in python string and also use .format on it?How do I lowercase a string in Python?Most elegant way to check if the string is empty in Python?
Why doesn't Gödel's incompleteness theorem apply to false statements?
How to preserve electronics (computers, ipads, phones) for hundreds of years?
What should be the ideal length of sentences in a blog post for ease of reading?
How can I, as DM, avoid the Conga Line of Death occurring when implementing some form of flanking rule?
Can you take a "free object interaction" while incapacitated?
Exposing a company lying about themselves in a tightly knit industry (videogames) : Is my career at risk on the long run?
Air travel with refrigerated insulin
Error in master's thesis, I do not know what to do
What is the period/term used describe Giuseppe Arcimboldo's style of painting?
categorizing a variable turns it from insignificant to significant
Capacitor electron flow
What is this high flying aircraft over Pennsylvania?
Has the laser at Magurele, Romania reached the tenth of the Sun power?
Are hand made posters acceptable in Academia?
Would a primitive species be able to learn English from reading books alone?
Would this string work as string?
Why can't I get pgrep output right to variable on bash script?
Should a narrator ever describe things based on a character's view instead of facts?
Strange behavior in TikZ draw command
Checking @@ROWCOUNT failing
Taking the numerator and the denominator
Toggle window scroll bar
When is the exact date for EOL of Ubuntu 14.04 LTS?
New Order #2: Turn My Way
Python take the string of anything, ignoring all escape characters [closed]
Convert JavaScript String to be all lower case?How do I parse a string to a float or int in Python?Python join: why is it string.join(list) instead of list.join(string)?Reverse a string in PythonConverting integer to string in Python?How to replace all occurrences of a string in JavaScriptDoes Python have a string 'contains' substring method?How can I print literal curly-brace characters in python string and also use .format on it?How do I lowercase a string in Python?Most elegant way to check if the string is empty in Python?
I am trying to make a function that takes typically copy-pasted text that very often includes n
characters. An example of such is as follows:
func('''This
is
some
text
that I entered''')
The problem with this function is the text can sometimes be rather large, so taking it line by line to avoid '
, "
or '''
isn't plausible. A piece of text that can cause issues is as follows:
func('''This
is'''
some"
text'
that I entered''')
I wanted to know if there is any way I can take the text as seen in the second example and use it as a string regardless of what it is comprised of.
Thanks!
python string string-literals
closed as unclear what you're asking by snakecharmerb, EdChum, greg-449, Pac0, RLave Mar 8 at 12:54
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
I am trying to make a function that takes typically copy-pasted text that very often includes n
characters. An example of such is as follows:
func('''This
is
some
text
that I entered''')
The problem with this function is the text can sometimes be rather large, so taking it line by line to avoid '
, "
or '''
isn't plausible. A piece of text that can cause issues is as follows:
func('''This
is'''
some"
text'
that I entered''')
I wanted to know if there is any way I can take the text as seen in the second example and use it as a string regardless of what it is comprised of.
Thanks!
python string string-literals
closed as unclear what you're asking by snakecharmerb, EdChum, greg-449, Pac0, RLave Mar 8 at 12:54
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
Are you looking to extract full strings, minus the newline characters? The output would beThis is some text that I entered
?
– kerwei
Mar 7 at 1:59
No, I'm looking to extract the full strings and the new line characters, so the output would beThisnis'''nnsome"ntext'nthat I entered
– Recessive
Mar 7 at 2:08
I don't understand what it is you're trying to do here. Can you provide an example of how this string causes a problem?
– snakecharmerb
Mar 8 at 8:25
add a comment |
I am trying to make a function that takes typically copy-pasted text that very often includes n
characters. An example of such is as follows:
func('''This
is
some
text
that I entered''')
The problem with this function is the text can sometimes be rather large, so taking it line by line to avoid '
, "
or '''
isn't plausible. A piece of text that can cause issues is as follows:
func('''This
is'''
some"
text'
that I entered''')
I wanted to know if there is any way I can take the text as seen in the second example and use it as a string regardless of what it is comprised of.
Thanks!
python string string-literals
I am trying to make a function that takes typically copy-pasted text that very often includes n
characters. An example of such is as follows:
func('''This
is
some
text
that I entered''')
The problem with this function is the text can sometimes be rather large, so taking it line by line to avoid '
, "
or '''
isn't plausible. A piece of text that can cause issues is as follows:
func('''This
is'''
some"
text'
that I entered''')
I wanted to know if there is any way I can take the text as seen in the second example and use it as a string regardless of what it is comprised of.
Thanks!
python string string-literals
python string string-literals
asked Mar 7 at 0:57
RecessiveRecessive
328212
328212
closed as unclear what you're asking by snakecharmerb, EdChum, greg-449, Pac0, RLave Mar 8 at 12:54
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as unclear what you're asking by snakecharmerb, EdChum, greg-449, Pac0, RLave Mar 8 at 12:54
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
Are you looking to extract full strings, minus the newline characters? The output would beThis is some text that I entered
?
– kerwei
Mar 7 at 1:59
No, I'm looking to extract the full strings and the new line characters, so the output would beThisnis'''nnsome"ntext'nthat I entered
– Recessive
Mar 7 at 2:08
I don't understand what it is you're trying to do here. Can you provide an example of how this string causes a problem?
– snakecharmerb
Mar 8 at 8:25
add a comment |
Are you looking to extract full strings, minus the newline characters? The output would beThis is some text that I entered
?
– kerwei
Mar 7 at 1:59
No, I'm looking to extract the full strings and the new line characters, so the output would beThisnis'''nnsome"ntext'nthat I entered
– Recessive
Mar 7 at 2:08
I don't understand what it is you're trying to do here. Can you provide an example of how this string causes a problem?
– snakecharmerb
Mar 8 at 8:25
Are you looking to extract full strings, minus the newline characters? The output would be
This is some text that I entered
?– kerwei
Mar 7 at 1:59
Are you looking to extract full strings, minus the newline characters? The output would be
This is some text that I entered
?– kerwei
Mar 7 at 1:59
No, I'm looking to extract the full strings and the new line characters, so the output would be
Thisnis'''nnsome"ntext'nthat I entered
– Recessive
Mar 7 at 2:08
No, I'm looking to extract the full strings and the new line characters, so the output would be
Thisnis'''nnsome"ntext'nthat I entered
– Recessive
Mar 7 at 2:08
I don't understand what it is you're trying to do here. Can you provide an example of how this string causes a problem?
– snakecharmerb
Mar 8 at 8:25
I don't understand what it is you're trying to do here. Can you provide an example of how this string causes a problem?
– snakecharmerb
Mar 8 at 8:25
add a comment |
1 Answer
1
active
oldest
votes
To my knowledge, you won't be able to paste the text directly into your file. However, you could paste it into a text file.
Use regex to find triple quotes '''
and other invalid characters.
Example python:
def read_paste(file):
import re
with open(file,'r') as f:
data = f.readlines()
for i,line in enumerate(data):
data[i] = re.sub('("|')',r'\1',line)
output = str()
for line in data:
output += line
return output
If what you say is true then this question simply doesn't have an answer. While this is a valid way of saving the example strings I gave into a string object, it wont work for inside the file, so I can't mark this as answered
– Recessive
Mar 7 at 3:10
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
To my knowledge, you won't be able to paste the text directly into your file. However, you could paste it into a text file.
Use regex to find triple quotes '''
and other invalid characters.
Example python:
def read_paste(file):
import re
with open(file,'r') as f:
data = f.readlines()
for i,line in enumerate(data):
data[i] = re.sub('("|')',r'\1',line)
output = str()
for line in data:
output += line
return output
If what you say is true then this question simply doesn't have an answer. While this is a valid way of saving the example strings I gave into a string object, it wont work for inside the file, so I can't mark this as answered
– Recessive
Mar 7 at 3:10
add a comment |
To my knowledge, you won't be able to paste the text directly into your file. However, you could paste it into a text file.
Use regex to find triple quotes '''
and other invalid characters.
Example python:
def read_paste(file):
import re
with open(file,'r') as f:
data = f.readlines()
for i,line in enumerate(data):
data[i] = re.sub('("|')',r'\1',line)
output = str()
for line in data:
output += line
return output
If what you say is true then this question simply doesn't have an answer. While this is a valid way of saving the example strings I gave into a string object, it wont work for inside the file, so I can't mark this as answered
– Recessive
Mar 7 at 3:10
add a comment |
To my knowledge, you won't be able to paste the text directly into your file. However, you could paste it into a text file.
Use regex to find triple quotes '''
and other invalid characters.
Example python:
def read_paste(file):
import re
with open(file,'r') as f:
data = f.readlines()
for i,line in enumerate(data):
data[i] = re.sub('("|')',r'\1',line)
output = str()
for line in data:
output += line
return output
To my knowledge, you won't be able to paste the text directly into your file. However, you could paste it into a text file.
Use regex to find triple quotes '''
and other invalid characters.
Example python:
def read_paste(file):
import re
with open(file,'r') as f:
data = f.readlines()
for i,line in enumerate(data):
data[i] = re.sub('("|')',r'\1',line)
output = str()
for line in data:
output += line
return output
answered Mar 7 at 1:59
Sean ChristiansSean Christians
215
215
If what you say is true then this question simply doesn't have an answer. While this is a valid way of saving the example strings I gave into a string object, it wont work for inside the file, so I can't mark this as answered
– Recessive
Mar 7 at 3:10
add a comment |
If what you say is true then this question simply doesn't have an answer. While this is a valid way of saving the example strings I gave into a string object, it wont work for inside the file, so I can't mark this as answered
– Recessive
Mar 7 at 3:10
If what you say is true then this question simply doesn't have an answer. While this is a valid way of saving the example strings I gave into a string object, it wont work for inside the file, so I can't mark this as answered
– Recessive
Mar 7 at 3:10
If what you say is true then this question simply doesn't have an answer. While this is a valid way of saving the example strings I gave into a string object, it wont work for inside the file, so I can't mark this as answered
– Recessive
Mar 7 at 3:10
add a comment |
Are you looking to extract full strings, minus the newline characters? The output would be
This is some text that I entered
?– kerwei
Mar 7 at 1:59
No, I'm looking to extract the full strings and the new line characters, so the output would be
Thisnis'''nnsome"ntext'nthat I entered
– Recessive
Mar 7 at 2:08
I don't understand what it is you're trying to do here. Can you provide an example of how this string causes a problem?
– snakecharmerb
Mar 8 at 8:25