reg ex for searching filenames [closed] - python

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I want to select the files, whose names ends with _90.jpeg|_180.jpeg|_270.jpeg|_90.jpg|_180.jpg|_270.jpg.
currently I am using the following approach
pattern = re.compile('_90.jpeg|_180.jpeg|_270.jpeg|_90.jpg|_180.jpg|_270.jpg')
pattern.search(filename)
Is there any cleaner way to represent the _xxx.yyyy in regular expression.

You can use:
pattern = re.compile('(_9|_18|_27)0\.jpe?g$')
If any digits are fine:
pattern = re.compile('_\d+\.jpe?g$')

Related

ValueError: malformed node or string while converting string to list [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 days ago.
Improve this question
import ast
ast.literal_eval(df['cyberbullying_type'])
error
I was expecting to return back the string values as a list

time data '2020-07-09T00:00:00+05:30' does not match format "yyyy-MM-dd'T'HH:mm:ssZ" [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I am getting this error time data 2020-07-09T00:00:00+05:30 does not match format yyyy-MM-dd'T'HH:mm:ssZ please help
datetime.datetime.fromisoformat('2020-07-09T00:00:00+05:30')

Self is treated as a variable [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
While passing the parameters mp_neuron.fit(), it asks for a third parameter.
Can anyone explain why self is not being recognized
You haven't new a object for MPNeuron, it should be
mp_neuron = MPNeuron()
You're not instantiating the object.
mp_neuron = MPNeuron
This should be
mp_neuron = MPNeuron()

In python can I use comprehension in print just like in list? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I want to ask that if we can use comprehension in print statement in python.
Just like:
print(i for i in range(10))
This gives me an error. Is there any way that we can compress our code by comprehensive printing ??
Your code has no error, it returns a generator. Instead, make it a list:
print([i for i in range(10)])
or better, with the list function:
print(list(range(10)))

Convert perl regex to python [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
The regex expression I'm trying to convert is
my $host =~m/([^.])(\.swiss\.ch)/)
But I'm not getting the desired result
Supposing you want to be able to match *.swiss.ch domains and addresses:
import re
preg = re.compile(r'([^\.]+)\.swiss\.ch')

Categories

Resources