Skip to main content

All Questions

Tagged with
0 votes
3 answers
42 views

Is there a cleaner string cleaning for my string in python

I'm trying to make a dict from my sample string but I'm getting a sample source that is VERY dirty my working python snippet: dict(item.split(':', 1) for item in re.sub(' ', '', re.sub('"', ''...
Andrew Alsberge's user avatar
-3 votes
5 answers
136 views

Repeat the characters based on the preceding number in a string [closed]

I am a beginner in python and this is how I approached to the solution: I have divided the string into two lists- number list and character list. And then I multiplied them. Is there any other better ...
Lilly's user avatar
  • 13
-1 votes
1 answer
147 views

"Unterminated string literal" (when it is terminated) - Why does Python parsing differ from syntax highlighting on VSCode

yield f"data: {json.dumps({ 'status': 'success', 'message': 'Success', 'data': { 'response': response, ...
user avatar
1 vote
3 answers
74 views

Find str.contains in two large Pandas DataFrames

I have a large pandas DataFrames like below. import pandas as pd import numpy as np df = pd.DataFrame( [ ("1", "Dixon Street", "Auckland"), ("2&...
Totura's user avatar
  • 167
0 votes
0 answers
35 views

__str__ in python not respecting escape keys [duplicate]

So I'm learning about object oriented programming and the __str__ method, and I'm finding that when adding things to a list the formatting of the item is different to when I simply print a particular ...
The grumpy baker's user avatar
-1 votes
1 answer
48 views

How to include variables in a multiple line string in Python? [duplicate]

For example, I have the following: first_count = 5000 query = ''' { students(first: first_count) { id firstName college { id name location ...
winterlyrock's user avatar
-1 votes
2 answers
106 views

Why does this not print hello at the end but instead the letters are all scrambled

Im tying to create a effect that make the string "hello" gradually appear: import time text = "hello" alphebet = [ "a", "b", "c", "d", &...
Jakob Brooks's user avatar
-4 votes
1 answer
56 views

Regex consonant mismatch [closed]

I am trying to use Python and regex to search for words that look in certain defined ways. Can anyone tell me why the following code returns the word "choosy" as part of the output? I ...
Mikkel Marqvorsen's user avatar
1 vote
1 answer
63 views

Replace characters before a number to a new character after the number python

I have some strings look like: *.rem.1.gz and *.rem.2.gz And I want to replace it into *.1.trim.gz and *.2.trim.gz The number 1 and number two files are paired with each other, which I want to create ...
Pluto Liu's user avatar
0 votes
1 answer
63 views

Unicode strings in a purely python3 codebase - are these useless? [duplicate]

In the codebase that I'm working on, there seems to be remnants of python2 because a lot of the strings are prefixed with u. From researching, it looks like this denotes a unicode string, but in ...
NFeruch - FreePalestine's user avatar
0 votes
1 answer
48 views

Find a Substring in String with Boardtools is not working if the string contains special chars

Today I got frustrated. I'm implementing a very simple logic with substring finding; it turned out to be a more complex situation. Let's consider this small python code: word_one, word_two = ['(/ %$ss%...
Allan Karlson's user avatar
1 vote
1 answer
91 views

Python 3 process non-printable characters in a unicode string [duplicate]

I'm reading text that contains non-printable characters such as backspaces from a file example.log. If I'm reading the content of the file in a terminal running cat example.log, I obtain a well ...
m.raynal's user avatar
  • 3,153
0 votes
3 answers
353 views

Multiple substrings in string python within variable check [duplicate]

I have the following code: check = "red" in string_to_explore How can I replicate it for multiple substrings? I tried with: check = "red|blue" in string_to_explore but doesn't ...
iraciv94's user avatar
  • 840
-2 votes
2 answers
126 views

How to get a single slash in the string?

Image: I have the following string: 'To reach the peak \\U0001fa77' It is clear that the last part is the emoji symbol, but it has to slashes before it, so when I print the string, I get 'To reach ...
Anna Denisova's user avatar
-2 votes
1 answer
54 views

When I tried to count the string of translated language (tamil) in Python, it didn't give me the correct count why?

code I tried to count the string for the name 'KUMAR' with length function, output came 5 it is correct. But when I tried to count the same name in a different language(Tamil) the output I expected ...
Manoj's user avatar
  • 1

15 30 50 per page
1
2 3 4 5
253