def parse_wizofoz(): page = render_template('wizofoz.html') links = get_chap_links(page) sections = {} for ind in range(len(links)): section = {} start = links[ind] if ind < len(links) - 1: end = links[ind + 1] patt = ('<A NAME="{}"></A>').format(start,end) match = re.search(patt,page,re.MULTILINE|re.DOTALL) else: patt = '<A NAME="{}"></A>(.*)<pre>'.format(start) match = re.searh(patt,page,re.MULTILINE|re.DOTALL) if match: soup = BeautifulSoup(match.group(1)) plist = [p.contents[0] for p in soup.find_all('p')] section['title'] = (soup.find('h3').contents)[0] section['plist'] = plist sections[start] = section return links, sections
Traceback (most recent call last): File "<pyshell#8>", line 1, in <module> re.search('c/a','abbd\nc').group() AttributeError: 'NoneType' object has no attribute 'group' >>> re.search('c/a','abbdnc') >>> re.search('c|a','abbdnc') <_sre.SRE_Match object; span=(0, 1), match='a'> >>> re.search('c|a|d','candjndk') <_sre.SRE_Match object; span=(0, 1), match='c'> >>> re.findall('a|b|g','abdggnsj andi') ['a', 'b', 'g', 'g', 'a'] >>> re.search('abcd','abcdgnsj abcd') <_sre.SRE_Match object; span=(0, 4), match='abcd'> >>> re.findall('abcd','abcdgnsj abcd') ['abcd', 'abcd'] >>> re.searh(r'\w\w\w\w','abcdgnsj abcd') Traceback (most recent call last): File "<pyshell#15>", line 1, in <module> re.searh(r'\w\w\w\w','abcdgnsj abcd') AttributeError: module 're' has no attribute 'searh' >>> re.search(r'\w\w\w\w','abcdgnsj abcd') <_sre.SRE_Match object; span=(0, 4), match='abcd'> >>> re.search('\w\w\w\w','abcdgnsj abcd') <_sre.SRE_Match object; span=(0, 4), match='abcd'> >>> re.search('\w\w\w','ab_cdfr ksitv') <_sre.SRE_Match object; span=(0, 3), match='ab_'> >>> re.search('\w\w\w','ab!!cdfr ksitv') <_sre.SRE_Match object; span=(4, 7), match='cdf'> >>> re.search('\w\w\w','ab!!cdr ksitv') <_sre.SRE_Match object; span=(4, 7), match='cdr'> >>> re.search('\w\w\w','ab!!cd+ks#tv')
import re value=[] items=[x for x in input("nhập mật khẩu:").split(',')] # ############ for p in items: if len(p)<6 or len(p)>12: continue else: pass if not re.searh("[a-z]",p): continue elif not re.search("[0-9]",p): continue elif not re.search("[A-Z]",p): continue elif not re.search("[$#@]",p): continue elif re.search("\s",p): continue else: pass value.append(p) print(",".join(value))
record.write('\t nopolar \t ploar \t charged \t armoatic') def() result=0 fro x in range(0,b) result=seq.count(X[x]) result=result+result a=float(result)/float(len(seq)) record.write(('%.3f \t')%a) for seq_record in SeqIO.parse(in_file,'fasta') import re in_text=open('text.text','r') text=in_text.readline() pattern=r"nonpolar: ([AIGLMV]+) +polar([CNPQST]+) +charged: ([DEHKR]+) +aromatic([FYW]+)" match=re.searh(pattern,text) record.write('\n %s \t')%(seq_record.id) seq=seq_record.seq Y=0 While True: Y=Y+1 if Y==1: X=match.group(1) b=len(X) D1() elif Y==2: X=match.group(2) b=len(X) D1() elif Y==3: