Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I work with Python 2.7. It is my first question here.
Here is my code:
import re
string = "0581111105822222749533333"
result = re.findall(r'058',string) # ['058', '058']
I want to add 5 digits after 058 and receive:
# ['05811111','05822222']
How to do this?
Thank you.
You can extract what you need using 058\d{5} pattern. This matches '058' characters and keeps extracting 5 digits after those.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 days ago.
Improve this question
Suppose a user wants to add a character or number to an existing string after randomly generating it, how do you add a character to a string?
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 days ago.
Improve this question
I want to know how when somebody uses a slash command and puts a id / number it will store that id and if they use it again it will give them the same answer but im using import random.
Can someone just drop a code below or tell me how please?
Didn't try anything yet.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I would like to create this for loop, but the text in the loop is quoted.
How can this be done please?
Thank you!
https://prnt.sc/tvutcl
in your image is in quotes, is an f-string, but they forgot to add the f
year = [2016,2017,2018,2019,2020]
for i in year:
rtx_price = (data.loc[f'{year}-07-31', 'RTX'])
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
search?query=EasterGmPromo2020&searchType=mktgattribute&monet=CURATED&fulfillment=all
I have such type of strings. I wanted to get data from ?query=EasterGmPromo2020 only. How to do in regex.
This is a query string. There are many packages out there that parse URLs, no need for regex here.
One way is to use urllib.parse (built into Python 3)
from urllib import parse
params = parse.parse_qs("query=EasterGmPromo2020&searchType=mktgattribute&monet=CURATED&fulfillment=all")
print(params["query"])
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
how can we write this single statement code into multiple lines?
I can understand only for loop written in multiple lines. Anyone, please break this code into multiple line code.
amp.append([amp[i] for i in ida])
By a for loop:
l = []
for i in ida:
l.append(amp[i])
amp.append(l)