Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
there's a form (pyqt5), i take date from it:
def buttonclicked(self):
since = self.Since.text()
Then I put that since here:
result, data = mail.search(None, '(SINCE {since} )'.format(since=since))
Error is :
b'[CANNOT] Unsupported search criterion: SINCE 10-09-2019 '
The date needs to match the following format:
imap.search(None, '(SINCE 10-Sep-2019)')
SEARCH BEFORE/AFTER with Pythons imaplib
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 2 years ago.
Improve this question
answer=input(print('What s the capital',country,'?'))
RETURN
What s the capital of South Africa ?
None
And I have to put my answer just after the 'none'
You are printing inside the input function and print returns None.
You should do something like this:
country = "Italy"
answer = input(f"What's the capital of {country}? ")
print(answer)
Read the documentation here.
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
I am having a sentence as below
Eg:
Original Strings can be in below formats.
"[PartnerID:2012345][Failure] Caused by :This is the Failure Name"
"[Failure] caused by This is the failure name"
"Reliability: oscrash in This is the failure name"
I want the string to be trimmed to This is the Failure Name.
Can anyone please help me in writing code for this in python?
Sorry, I had left out other sentences before
Let:
str1 = "[PartnerID:2012345][Failure] Caused by :This is the Failure Name"
To get what you require, we split:
res = str1.split(":")[-1]
if it is like:
str1 = "[PartnerID:2012345][Failure] Caused by This is the Failure Name"
then you can:
res = str1.split("Caused by ")[-1]
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 3 years ago.
Improve this question
I am trying to separate all the images from the following string.
how can I get a list of images that start with "comp1/img_" and are either split by a "," or a ";"
/*jsonp*/jsonresp({"img_set":"comp1/img_23434;comp1/img_3243r43r,comp1/img_o43nfjr;comp1/img_wjfno43,comp1/img_nrejfner;comp1/img_jrenckerjv,comp1/img_23434k;comp1/img_rkfnk4n"},"fknreff\",");
so I would end up with a list like...
comp1/img_23434
comp1/img_3243r43r
comp1/img_o43nfjr
comp1/img_wjfno43
comp1/img_nrejfner
comp1/img_jrenckerjv
comp1/img_23434k
comp1/img_rkfnk4n
any help would be appreciated.
thanks
You can do this:
>>> data = '/*jsonp*/jsonresp({"img_set":"comp1/img_23434;comp1/img_3243r43r,comp1/img_o43nfjr;comp1/img_wjfno43,comp1/img_nrejfner;comp1/img_jrenckerjv,comp1/img_23434k;comp1/img_rkfnk4n"},"fknreff\",");'
>>> import re
>>> re.findall(r'comp1/img_[^;,"]+', data)
['comp1/img_23434', 'comp1/img_3243r43r', 'comp1/img_o43nfjr', 'comp1/img_wjfno43', 'comp1/img_nrejfner', 'comp1/img_jrenckerjv', 'comp1/img_23434k', 'comp1/img_rkfnk4n']
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I am looking for nice alternative for this part of code:
def reportResult (finalParsResult):
print "Total Number of Mimatch Files:",
diffSum=0
for (gP, matchFiles, diffFiles, matchFolders, gpExtrFld, upExtraFldrs) in FinalResult:
diffSum=diffSum+len(diffFiles)
print "Number of diff files", diffSum
Any suggestion?
def reportResult(finalParsResult):
return sum(len(result_row[2]) for result_row in FinalResult)
Or, if FinalResult should actually be the parameter finalParsResult:
def reportResult(finalParsResult):
return sum(len(result_row[2]) for result_row in finalParsResult)
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 6 years ago.
Improve this question
I have a string
<b>Status : Active<br>Code : C1654<br><br>Shop <a class="top"<b>Shop A</b></a></b>
And I want get Active , C1654 and Shop A.
How to do the same thing in Python?
use python re module
(you didn't explain the pattern you wanted to follow so I can just give an example that will work for the above string):
import re
results = []
reg = '.*?>.*?: (.+?)<br'
my_str = '<b>Status : Active<br>Code : C1654<br><br>Shop <a class="top"<b>Shop A</b></a></b>'
results+=re.findall(reg,my_str)
reg2 = '<a.*?<b>(.*?)</b>'
results += re.findall(reg2,my_str)
print result
>>>['Active', 'C1654', 'Shop A']
I hope I helped