正则表达式(python3)

文章目录

  • 正则表达式(python3)
    • match方法
    • search方法
    • 常用匹配符
    • 泽一匹配符(|)和列表
    • 重复数量限定符
    • 原生字符串
    • 边界字符
    • 分组
    • 其他常用函数
      • sub、subn函数
      • compile函数
      • findall函数
      • split函数

正则表达式(python3)

正则表达式是对字符操作的一种逻辑公式,就是用事先定义好的一些特定字符以及这些特定字符的组合,组成一个“规则字符串”,这个“规则字符串”用来表达对字符串的一种过滤逻辑(可以用来截取或替换操作)

作用

1.给定的字符串是否符合正则表达式的过滤逻辑(称作“匹配")。

2.可以通过正则表达式,从字符串中获取我们想要的特定部分。

3.还可以对目标字符串进行替换操作。

match方法

re.match尝试从字符串的起始位置匹配一个模式,如果不是起始位置匹配成功的话,match()就返回None。

re.match(pattern,string,flags = 0)

函数参数说明

参数 描述
pattern 匹配的正则表达式
string 要匹配的字符串
flags 标志位,用于控制正则表达式的匹配方式,
例:是否区分大小写,多行匹配等等(可选标志)
修饰符 描述
re.I 使匹配对大小写不敏感
re.L 做本地化识别(localle-aware)匹配
re.M 多行匹配,影响^ $
re.S 匹配包括换行在内的所有字符
re.U 根据Unicode字符集解析字符。影响\w,\W,\b,\B
re.X 该标志给予更灵活的格式
#match方法的使用
import re
s = 'hello python'
pattern = 'Hello'
o = re.match(pattern,s,re.I)
print(re.match(pattern,s))
print(dir(o))#查看当前对象使用了什么方法
print(o.group())#返回匹配的字符串
print(o.span())#匹配字符串的范围
print(o.start())

search方法

re.match(pattern,string,flags = 0)

search函数参数说明

参数 描述
pattern 匹配的正则表达式
string 要匹配的字符串
flags 标志位,用于控制正则表达式的匹配方式,
例:是否区分大小写,多行匹配等等(可选标志)

search与match的区别

re.match只匹配字符串的开始,如果字符串开始不符合正则表达式,则匹配失败,函数返回None,而re.search匹配整个字符串,直到找到一个匹配。

m = 'i love you'
print(re.search('love',m))
print(re.match('love',m))
###################结果#############################
<re.Match object; span=(2, 6), match='love'>
None

常用匹配符

符号 描述
. 匹配任意一个字符(除了\n)
[] 匹配列表中的字符串
\w 匹配字母、数字、下划线(a-z,A-Z,0-9,_)
\W 匹配不是字母,数字,下划线
\s 匹配空白字符,(空格\n\t)
\S 匹配不是空白的字符
\d 匹配数字(0-9)
\D 匹配非数字的字符

部分匹配符测试

#
import re
##########.的使用###############
q = 'a'
w = 'A'
e = '_'
r = '\n'
pattern = '.'
q1 = re.match(pattern,q)
w1 = re.match(pattern,w)
e1 = re.match(pattern,e)
r1 = re.match(pattern,r)
print(q1,'\n',w1,'\n',e1,'\n',r1)
#########\d的使用###########
q = '0123'#由结果看只能匹配一个
w = '5'
e = 'a'
r = ' 9'
pattern = '\d'
q1 = re.match(pattern,q)
w1 = re.match(pattern,w)
e1 = re.match(pattern,e)
r1 = re.match(pattern,r)
print(q1,'\n',w1,'\n',e1,'\n',r1)
##########\s的使用#############
q = ' '
w = '\n'
e = '\t'
r = '_'
pattern = '\s'
q1 = re.match(pattern,q)
w1 = re.match(pattern,w)
e1 = re.match(pattern,e)
r1 = re.match(pattern,r)
print(q1,'\n',w1,'\n',e1,'\n',r1)
##############[]的使用#############
q = '2'
w = '3'
e = '4'
pattern = '[2468]'
q1 = re.match(pattern,q)
w1 = re.match(pattern,w)
e1 = re.match(pattern,e)
print(q1,'\n',w1,'\n',e1)


#################测试结果#########################################

<re.Match object; span=(0, 1), match='a'> 
 <re.Match object; span=(0, 1), match='A'> 
 <re.Match object; span=(0, 1), match='_'> 
 None
<re.Match object; span=(0, 1), match='0'> 
 <re.Match object; span=(0, 1), match='5'> 
 None 
 None
<re.Match object; span=(0, 1), match=' '> 
 <re.Match object; span=(0, 1), match='\n'> 
 <re.Match object; span=(0, 1), match='\t'> 
 None
<re.Match object; span=(0, 1), match='2'> 
 None 
 <re.Match object; span=(0, 1), match='4'>

Process finished with exit code 0

泽一匹配符(|)和列表

import re
#泽一和列表的相同点
pattern = '[xyz]'
pa1 = 'x|y|z'
s = 'z'
o = re.search(pattern,s)
o1 = re.search(pa1,s)
print(o,'\n',o1)
print('#########不同点#######')
#泽一和列表的不同点
pattern = '[ab][cd]'
pa1 = 'ab|cd'
s1 = 'bc'
s2 = 'ab'
o1 = re.search(pattern,s1)
o2 = re.search(pattern,s2)
a1 = re.search(pa1,s1)
a2 = re.search(pa1,s2)
print(o1,'\n',o2,'\n',a1,'\n',a2)




################结果##############################
<re.Match object; span=(0, 1), match='z'> 
 <re.Match object; span=(0, 1), match='z'>
#########不同点#######
<re.Match object; span=(0, 2), match='bc'> 
 None 
 None 
 <re.Match object; span=(0, 2), match='ab'>

Process finished with exit code 0

重复数量限定符

提供了对表达式的一部分进行重复处理的功能。

正则表达式中常用的限定符

符号 描述
* 匹配零次或多次
+ 匹配一次或多次
匹配一次或零次
{m} 重复m次
{m,n} 重复m到n次
{m,} 至少m次

部分限定符测试

import re
#############*的使用############
pattern = '\d*'
q = '123qwe'
w = '12345qwe'
e = 'qwe'
q1 = re.match(pattern,q)
w1 = re.match(pattern,w)
e1 = re.match(pattern,e) #匹配空
print(q1,'\n',w1,'\n',e1)
#############+的使用############
pattern = '\d+'
q = '123qwe'
w = '12345qwe'
e = 'qwe'
q1 = re.match(pattern,q)
w1 = re.match(pattern,w)
e1 = re.match(pattern,e)
print(q1,'\n',w1,'\n',e1)
#############{}的使用############
pattern = '\d{2}'
pa1 = '\d{1,}'
q = '123qwe'
w = '1qwe'
e = 'qwe'
q1 = re.match(pattern,q)
w1 = re.match(pattern,w)
e1 = re.match(pa1,e)
q2 = re.match(pa1,q)
w2 = re.match(pa1,w)
e2 = re.match(pa1,e)
print(q1,'\n',w1,'\n',e1)
print(q2,'\n',w2,'\n',e2)


##################结果#######################################
<re.Match object; span=(0, 3), match='123'> 
 <re.Match object; span=(0, 5), match='12345'> 
 <re.Match object; span=(0, 0), match=''>
<re.Match object; span=(0, 3), match='123'> 
 <re.Match object; span=(0, 5), match='12345'> 
 None
<re.Match object; span=(0, 2), match='12'> 
 None 
 None
<re.Match object; span=(0, 3), match='123'> 
 <re.Match object; span=(0, 1), match='1'> 
 None

Process finished with exit code 0

原生字符串

正则表达式里使用“\”作为转移字符。

Python中字符串前面加上 r 表示原生字符串

例:在输出路径的时候要使用两次反斜杠

import re
print('c:\\a\\c\\d')
s = '\\t123'
pattern = '\\\\t\d*'
o = re.match(pattern,s)
pa1 = r'\\t\d*'
o1 = re.match(pa1,s)
print(o,'\n',o1)

############输出结果#################################

c:\a\c\d
<re.Match object; span=(0, 5), match='\\t123'> 
 <re.Match object; span=(0, 5), match='\\t123'>

Process finished with exit code 0

边界字符

字符 功能
^ 匹配字符串开头
$ 匹配字符串结尾
\b 匹配一个单词的边界
\B 匹配非单词的边界

示例

import re
#匹配QQ邮箱,数字5,10位
# $的使用
a = '[email protected]'
b = '[email protected]'
pattern = '[1-9]\d{4,9}@qq.com'
pa1 = '[1-9]\d{4,9}@qq.com$'
q1 = re.match(pattern,a)
w1 = re.match(pattern,b)
q2 = re.match(pa1,a)
w2 = re.match(pa1,b)
print(q1,'\n',w1,'\n',q2,'\n',w2)
# ^的使用
a = 'hello world'
b = 'python'
pattern = 'hello.*'
pa1 = r'^hello.*'
q1 = re.match(pattern,a)
w1 = re.match(pattern,b)
q2 = re.match(pa1,a)
w2 = re.match(pa1,b)
print(q1,'\n',w1,'\n',q2,'\n',w2)
# \b的使用
a = '1234 abc'
b = '123 ab'
pattern = r'.*\bab'
pa1 = r'.*ab\b'
q1 = re.match(pattern,a)
w1 = re.match(pattern,b)
q2 = re.match(pa1,a)
w2 = re.match(pa1,b)
print(q1,'\n',w1,'\n',q2,'\n',w2)


#########################结果##########################
<re.Match object; span=(0, 13), match='[email protected]'> 
 <re.Match object; span=(0, 13), match='[email protected]'> 
 <re.Match object; span=(0, 13), match='[email protected]'> 
 None
<re.Match object; span=(0, 11), match='hello world'> 
 None 
 <re.Match object; span=(0, 11), match='hello world'> 
 None
<re.Match object; span=(0, 7), match='1234 ab'> 
 <re.Match object; span=(0, 6), match='123 ab'> 
 None 
 <re.Match object; span=(0, 6), match='123 ab'>

Process finished with exit code 0

分组

一个模式中有用一对圆括号括起来的部分,那么这个部分就会作为一组,可以通过group方法的参数获取指定的组匹配的字符串。

字符 功能
(ab) 将括号中的字符作为一个分组
\num 引用分组num匹配到的字符串
(?p) 分别起组名
(?p=name) 引用别名为name分组匹配到的字符串

示例

import re
#匹配座机号码 区号-电话号码 010-43222 0432-447721
#(ab)的使用
pa = '(\d{3,4})-([1-9]\d{4,7}$)'
s = '010-43222'
o = re.search(pa,s)
print(o.group())
print(o.group(1))
print(o.groups())
print(o.groups()[0])

#########################结果#############################
010-43222
010
('010', '43222')
010
#\num的使用
pattern = r'<(.+)><(.+)>.+'
s = 'head部分'
s1 = 'head部分</head></body>'</span>
o <span class="token operator">=</span> re<span class="token punctuation">.</span>search<span class="token punctuation">(</span>pattern<span class="token punctuation">,</span>s<span class="token punctuation">)</span>
o1 <span class="token operator">=</span> re<span class="token punctuation">.</span>search<span class="token punctuation">(</span>pattern<span class="token punctuation">,</span>s1<span class="token punctuation">)</span>
<span class="token keyword">print</span><span class="token punctuation">(</span>o<span class="token punctuation">,</span><span class="token string">'\n'</span><span class="token punctuation">,</span>o1<span class="token punctuation">)</span>
<span class="token comment">#########################结果#############################</span>
<span class="token operator"><</span>re<span class="token punctuation">.</span>Match <span class="token builtin">object</span><span class="token punctuation">;</span> span<span class="token operator">=</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">32</span><span class="token punctuation">)</span><span class="token punctuation">,</span> match<span class="token operator">=</span><span class="token string">'<html><head>head部分</head></html>'</span><span class="token operator">></span> 
 <span class="token boolean">None</span>
</code></pre> 
  <pre><code class="prism language-python"><span class="token comment">#(?p<name)</span>
pattern <span class="token operator">=</span> r<span class="token string">'<(?P<k_html>.+)><(?P<k_head>.+)>.+</(?P=k_head)></(?P=k_html)>'</span>
s <span class="token operator">=</span> <span class="token string">'<html><head>head部分</head></html>'</span>
s1 <span class="token operator">=</span> <span class="token string">'<html><title>head部分</head></body>'</span>
o <span class="token operator">=</span> re<span class="token punctuation">.</span>search<span class="token punctuation">(</span>pattern<span class="token punctuation">,</span>s<span class="token punctuation">)</span>
o1 <span class="token operator">=</span> re<span class="token punctuation">.</span>search<span class="token punctuation">(</span>pattern<span class="token punctuation">,</span>s1<span class="token punctuation">)</span>
<span class="token keyword">print</span><span class="token punctuation">(</span>o<span class="token punctuation">,</span><span class="token string">'\n'</span><span class="token punctuation">,</span>o1<span class="token punctuation">)</span>
<span class="token comment">#########################结果#############################</span>
<span class="token operator"><</span>re<span class="token punctuation">.</span>Match <span class="token builtin">object</span><span class="token punctuation">;</span> span<span class="token operator">=</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">32</span><span class="token punctuation">)</span><span class="token punctuation">,</span> match<span class="token operator">=</span><span class="token string">'<html><head>head部分</head></html>'</span><span class="token operator">></span> 
 <span class="token boolean">None</span>
</code></pre> 
  <h2>其他常用函数</h2> 
  <h3>sub、subn函数</h3> 
  <p>sub函数和subn函数用于实现搜索和替换功能。这两个函数的功能几乎完全相同,都是将某个字符串中所有匹配正则表达式的部分替换成其他字符串。用来替换的部分可能是一个字符串,也可以是一个函数,该函数返回一个用来替换的字符串。</p> 
  <blockquote> 
   <p>sub函数返回替换后的结果,subn 函数返回一个元组,元组的第1个元素是替换后的结果,第2个元素是替换的总<br> 数。</p> 
  </blockquote> 
  <p>语法格式如下:</p> 
  <pre><code class="prism language-python">re<span class="token punctuation">.</span>sub<span class="token punctuation">(</span>pattern<span class="token punctuation">,</span> repl string<span class="token punctuation">,</span> count<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">,</span>flags<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">)</span>

</code></pre> 
  <pre><code class="prism language-python"><span class="token keyword">import</span> re
<span class="token comment">#sub和subn的使用</span>
s <span class="token operator">=</span> <span class="token string">'2021-959-456 # 这是一个国外的电话 123'</span>
pa1 <span class="token operator">=</span> r<span class="token string">'#.*'</span>
pa2 <span class="token operator">=</span> r<span class="token string">'#\D*'</span>
result1 <span class="token operator">=</span> re<span class="token punctuation">.</span>sub<span class="token punctuation">(</span>pa1<span class="token punctuation">,</span><span class="token string">""</span><span class="token punctuation">,</span>s<span class="token punctuation">)</span>
result2 <span class="token operator">=</span> re<span class="token punctuation">.</span>sub<span class="token punctuation">(</span>pa2<span class="token punctuation">,</span><span class="token string">""</span><span class="token punctuation">,</span>s<span class="token punctuation">)</span>
result3 <span class="token operator">=</span> re<span class="token punctuation">.</span>subn<span class="token punctuation">(</span>pa2<span class="token punctuation">,</span><span class="token string">""</span><span class="token punctuation">,</span>s<span class="token punctuation">)</span>
<span class="token keyword">print</span><span class="token punctuation">(</span>result1<span class="token punctuation">)</span>
<span class="token keyword">print</span><span class="token punctuation">(</span>result2<span class="token punctuation">)</span>
<span class="token keyword">print</span><span class="token punctuation">(</span>result3<span class="token punctuation">,</span><span class="token string">'\t'</span><span class="token punctuation">,</span>result3<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">,</span><span class="token string">'\t'</span><span class="token punctuation">,</span>result3<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
<span class="token comment">#########################结果#############################</span>
<span class="token number">2021</span><span class="token operator">-</span><span class="token number">959</span><span class="token operator">-</span><span class="token number">456</span> 
<span class="token number">2021</span><span class="token operator">-</span><span class="token number">959</span><span class="token operator">-</span><span class="token number">456</span> <span class="token number">123</span>
<span class="token punctuation">(</span><span class="token string">'2021-959-456 123'</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">)</span> 	 <span class="token number">2021</span><span class="token operator">-</span><span class="token number">959</span><span class="token operator">-</span><span class="token number">456</span> <span class="token number">123</span> 	 <span class="token number">1</span>
</code></pre> 
  <h3>compile函数</h3> 
  <p>compile函数用于编译正则表达式,生成一个正则表达式(Pattern)对象,供match()和search()使用。</p> 
  <p>语法格式:</p> 
  <pre><code class="prism language-python">re<span class="token punctuation">.</span><span class="token builtin">compile</span><span class="token punctuation">(</span>pattern<span class="token punctuation">[</span> flags<span class="token punctuation">]</span><span class="token punctuation">)</span>

</code></pre> 
  <p>参数说明</p> 
  <table> 
   <thead> 
    <tr> 
     <th>参数</th> 
     <th>描述</th> 
    </tr> 
   </thead> 
   <tbody> 
    <tr> 
     <td>pattern</td> 
     <td>一个字符串形式的正则表达式</td> 
    </tr> 
    <tr> 
     <td>flags</td> 
     <td>可选,表示匹配模式,例如:忽略大小写,多行模式等</td> 
    </tr> 
   </tbody> 
  </table> 
  <pre><code class="prism language-python"><span class="token comment">#compile</span>
s <span class="token operator">=</span> <span class="token string">'2021-959-456 # 这是一个国外的电话 123'</span>
pattern <span class="token operator">=</span> re<span class="token punctuation">.</span><span class="token builtin">compile</span><span class="token punctuation">(</span>r<span class="token string">'\w*'</span><span class="token punctuation">)</span>
o <span class="token operator">=</span> pattern<span class="token punctuation">.</span>search<span class="token punctuation">(</span>s<span class="token punctuation">)</span>
<span class="token keyword">print</span><span class="token punctuation">(</span>o<span class="token punctuation">)</span>
<span class="token comment">#########################结果#############################</span>
<span class="token operator"><</span>re<span class="token punctuation">.</span>Match <span class="token builtin">object</span><span class="token punctuation">;</span> span<span class="token operator">=</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">,</span> match<span class="token operator">=</span><span class="token string">'2021'</span><span class="token operator">></span>
</code></pre> 
  <h3>findall函数</h3> 
  <p>在字符串中找到正则表达式所匹配的所有子串,并返回一个列表,如果没有找到匹配的,<br> 则返回空列表。语法格式如下:</p> 
  <pre><code class="prism language-python">findal<span class="token punctuation">[</span><span class="token punctuation">(</span>pattern<span class="token punctuation">,</span> string<span class="token punctuation">,</span> flags<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">)</span>

</code></pre> 
  <p>参数说明</p> 
  <table> 
   <thead> 
    <tr> 
     <th>参数</th> 
     <th>描述</th> 
    </tr> 
   </thead> 
   <tbody> 
    <tr> 
     <td>pattern</td> 
     <td>匹配的正则表达式</td> 
    </tr> 
    <tr> 
     <td>string</td> 
     <td>要匹配的字符串</td> 
    </tr> 
    <tr> 
     <td>flags</td> 
     <td>可选,表示匹配模式,例如:忽略大小写,多行模式等</td> 
    </tr> 
   </tbody> 
  </table> 
  <p>finditer函数</p> 
  <blockquote> 
   <p>和findall类似,在字符串中找到正则表达式所匹配的所有子串,并把它们作为一个迭代器返回</p> 
  </blockquote> 
  <pre><code class="prism language-python"><span class="token comment">#findall和finditer函数</span>
s <span class="token operator">=</span> <span class="token string">'first 1 second 2 third 3'</span>
pattern <span class="token operator">=</span> r<span class="token string">'\w+'</span>
o1 <span class="token operator">=</span> re<span class="token punctuation">.</span>findall<span class="token punctuation">(</span>pattern<span class="token punctuation">,</span>s<span class="token punctuation">)</span>
o2 <span class="token operator">=</span> re<span class="token punctuation">.</span>finditer<span class="token punctuation">(</span>pattern<span class="token punctuation">,</span>s<span class="token punctuation">)</span>
<span class="token keyword">print</span><span class="token punctuation">(</span>o1<span class="token punctuation">)</span>
<span class="token keyword">print</span><span class="token punctuation">(</span>o2<span class="token punctuation">)</span>
<span class="token keyword">for</span> i <span class="token keyword">in</span> o2<span class="token punctuation">:</span>
    <span class="token keyword">print</span><span class="token punctuation">(</span>i<span class="token punctuation">.</span>group<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>end<span class="token operator">=</span><span class="token string">"\t"</span><span class="token punctuation">)</span>
<span class="token comment">#########################结果#############################</span>
<span class="token punctuation">[</span><span class="token string">'first'</span><span class="token punctuation">,</span> <span class="token string">'1'</span><span class="token punctuation">,</span> <span class="token string">'second'</span><span class="token punctuation">,</span> <span class="token string">'2'</span><span class="token punctuation">,</span> <span class="token string">'third'</span><span class="token punctuation">,</span> <span class="token string">'3'</span><span class="token punctuation">]</span>
<span class="token operator"><</span>callable_iterator <span class="token builtin">object</span> at <span class="token number">0x000001BE65638668</span><span class="token operator">></span>
first	<span class="token number">1</span>	second	<span class="token number">2</span>	third	<span class="token number">3</span>
</code></pre> 
  <h3>split函数</h3> 
  <p>split函数用于根据正则表达式分隔字符串,也就是说,将字符串与模式匹配的子字符串都作为分隔符来分隔这个字符串。split 函数返回一个列表形式的分隔结果,每一个列表元素都是分隔的子字符串。</p> 
  <p>语法格式如下:</p> 
  <pre><code class="prism language-python">re<span class="token punctuation">.</span>split<span class="token punctuation">(</span>pattern<span class="token punctuation">,</span> string<span class="token punctuation">[</span> maxsplit<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">,</span> flags<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">)</span>

</code></pre> 
  <p>参数说明</p> 
  <table> 
   <thead> 
    <tr> 
     <th>参数</th> 
     <th>描述</th> 
    </tr> 
   </thead> 
   <tbody> 
    <tr> 
     <td>pattern</td> 
     <td>匹配的正则表达式</td> 
    </tr> 
    <tr> 
     <td>string</td> 
     <td>要匹配的字符串</td> 
    </tr> 
    <tr> 
     <td>maxsplit</td> 
     <td>分隔次数,maxsplit = 1分隔一次,默认为0,不限制次数</td> 
    </tr> 
    <tr> 
     <td>flags</td> 
     <td>可选,表示匹配模式,例如:忽略大小写,多行模式等</td> 
    </tr> 
   </tbody> 
  </table> 
  <pre><code class="prism language-python"><span class="token comment">#split函数</span>
s <span class="token operator">=</span> <span class="token string">'first1second22third 3'</span>
pattern <span class="token operator">=</span> r<span class="token string">'\d+'</span>
o1 <span class="token operator">=</span> re<span class="token punctuation">.</span>split<span class="token punctuation">(</span>pattern<span class="token punctuation">,</span>s<span class="token punctuation">)</span>
o2 <span class="token operator">=</span> re<span class="token punctuation">.</span>split<span class="token punctuation">(</span>pattern<span class="token punctuation">,</span>s<span class="token punctuation">,</span>maxsplit<span class="token operator">=</span><span class="token number">2</span><span class="token punctuation">)</span>
<span class="token keyword">print</span><span class="token punctuation">(</span>o1<span class="token punctuation">)</span>
<span class="token keyword">print</span><span class="token punctuation">(</span>o2<span class="token punctuation">)</span>
<span class="token comment">#########################结果#############################</span>
<span class="token punctuation">[</span><span class="token string">'first'</span><span class="token punctuation">,</span> <span class="token string">'second'</span><span class="token punctuation">,</span> <span class="token string">'third '</span><span class="token punctuation">,</span> <span class="token string">''</span><span class="token punctuation">]</span>
<span class="token punctuation">[</span><span class="token string">'first'</span><span class="token punctuation">,</span> <span class="token string">'second'</span><span class="token punctuation">,</span> <span class="token string">'third 3'</span><span class="token punctuation">]</span>
</code></pre> 
  <p>贪婪模式和非贪婪模式</p> 
  <p>贪婪模式指Python里数量词默认是贪婪的,总是尝试匹配尽可能多的字符。非贪婪模式与贪婪相反,总是尝试匹配尽可能少的字符,可以使用重复数量限定符后面加上?,使贪婪变成非贪婪。</p> 
  <pre><code class="prism language-python"><span class="token keyword">import</span> re

v <span class="token operator">=</span> re<span class="token punctuation">.</span>match<span class="token punctuation">(</span>r<span class="token string">'(.+)(\d+-\d+-\d+)'</span><span class="token punctuation">,</span><span class="token string">'This is my tel:133-1234-1234'</span><span class="token punctuation">)</span>
<span class="token keyword">print</span><span class="token punctuation">(</span><span class="token string">'--------贪婪模式-------'</span><span class="token punctuation">)</span>
<span class="token keyword">print</span><span class="token punctuation">(</span>v<span class="token punctuation">.</span>group<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
<span class="token keyword">print</span><span class="token punctuation">(</span>v<span class="token punctuation">.</span>group<span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
<span class="token keyword">print</span><span class="token punctuation">(</span><span class="token string">'--------非贪婪模式-------'</span><span class="token punctuation">)</span>
v <span class="token operator">=</span> re<span class="token punctuation">.</span>match<span class="token punctuation">(</span>r<span class="token string">'(.+?)(\d+-\d+-\d+)'</span><span class="token punctuation">,</span><span class="token string">'This is my tel:133-1234-1234'</span><span class="token punctuation">)</span>
<span class="token keyword">print</span><span class="token punctuation">(</span>v<span class="token punctuation">.</span>group<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
<span class="token keyword">print</span><span class="token punctuation">(</span>v<span class="token punctuation">.</span>group<span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
<span class="token comment">#########################结果#############################</span>
<span class="token operator">-</span><span class="token operator">-</span><span class="token operator">-</span><span class="token operator">-</span><span class="token operator">-</span><span class="token operator">-</span><span class="token operator">-</span><span class="token operator">-</span>贪婪模式<span class="token operator">-</span><span class="token operator">-</span><span class="token operator">-</span><span class="token operator">-</span><span class="token operator">-</span><span class="token operator">-</span><span class="token operator">-</span>
This <span class="token keyword">is</span> my tel<span class="token punctuation">:</span><span class="token number">13</span>
<span class="token number">3</span><span class="token operator">-</span><span class="token number">1234</span><span class="token operator">-</span><span class="token number">1234</span>
<span class="token operator">-</span><span class="token operator">-</span><span class="token operator">-</span><span class="token operator">-</span><span class="token operator">-</span><span class="token operator">-</span><span class="token operator">-</span><span class="token operator">-</span>非贪婪模式<span class="token operator">-</span><span class="token operator">-</span><span class="token operator">-</span><span class="token operator">-</span><span class="token operator">-</span><span class="token operator">-</span><span class="token operator">-</span>
This <span class="token keyword">is</span> my tel<span class="token punctuation">:</span>
<span class="token number">133</span><span class="token operator">-</span><span class="token number">1234</span><span class="token operator">-</span><span class="token number">1234</span>

Process finished <span class="token keyword">with</span> exit code <span class="token number">0</span>

</code></pre> 
 </div> 
</div>
                            </div>
                        </div>
                    </div>
                    <!--PC和WAP自适应版-->
                    <div id="SOHUCS" sid="1369943835240652800"></div>
                    <script type="text/javascript" src="/views/front/js/chanyan.js"></script>
                    <!-- 文章页-底部 动态广告位 -->
                    <div class="youdao-fixed-ad" id="detail_ad_bottom"></div>
                </div>
                <div class="col-md-3">
                    <div class="row" id="ad">
                        <!-- 文章页-右侧1 动态广告位 -->
                        <div id="right-1" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad">
                            <div class="youdao-fixed-ad" id="detail_ad_1"> </div>
                        </div>
                        <!-- 文章页-右侧2 动态广告位 -->
                        <div id="right-2" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad">
                            <div class="youdao-fixed-ad" id="detail_ad_2"></div>
                        </div>
                        <!-- 文章页-右侧3 动态广告位 -->
                        <div id="right-3" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad">
                            <div class="youdao-fixed-ad" id="detail_ad_3"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="container">
        <h4 class="pt20 mb15 mt0 border-top">你可能感兴趣的:(蓝桥杯)</h4>
        <div id="paradigm-article-related">
            <div class="recommend-post mb30">
                <ul class="widget-links">
                    <li><a href="/article/1835294507264995328.htm"
                           title="蓝桥杯18小白第5题" target="_blank">蓝桥杯18小白第5题</a>
                        <span class="text-muted">@liu666</span>
<a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/%E7%AE%97%E6%B3%95/1.htm">算法</a><a class="tag" taget="_blank" href="/search/%E8%81%8C%E5%9C%BA%E5%92%8C%E5%8F%91%E5%B1%95/1.htm">职场和发展</a>
                        <div>思维,#includeusingnamespacestd;#defineintlonglongconstintn=1e6+11;inta,b[n],c[n],d,k[n];structs{intx,y,z;}q[n];boolcmp(sa1,sa2){returna1.z>a;for(inti=1;i>q[i].x;}for(inti=1;i>q[i].y;q[i].z=q[i].x+q[i].y</div>
                    </li>
                    <li><a href="/article/1834629598130827264.htm"
                           title="蓝桥杯第十四届C++C组" target="_blank">蓝桥杯第十四届C++C组</a>
                        <span class="text-muted">bug~bug~</span>
<a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/c%2B%2B/1.htm">c++</a><a class="tag" taget="_blank" href="/search/c%E8%AF%AD%E8%A8%80/1.htm">c语言</a>
                        <div>目录三国游戏填充翻转【单调队列优化DP】子矩阵【快速幂、欧拉函数】互质数的个数【tire树】异或和之差【质因数分解】公因数匹配子树的大小三国游戏题目描述小蓝正在玩一款游戏。游戏中魏蜀吴三个国家各自拥有一定数量的士兵X,Y,Z(一开始可以认为都为0)。游戏有n个可能会发生的事件,每个事件之间相互独立且最多只会发生一次,当第i个事件发生时会分别让X,Y,Z增加Ai,Bi,Ci。当游戏结束时(所有事件的</div>
                    </li>
                    <li><a href="/article/1834628464221712384.htm"
                           title="【蓝桥杯】2.走出迷宫的最少步数——DFS" target="_blank">【蓝桥杯】2.走出迷宫的最少步数——DFS</a>
                        <span class="text-muted">电次电次</span>
<a class="tag" taget="_blank" href="/search/%E6%B7%B1%E5%BA%A6%E4%BC%98%E5%85%88/1.htm">深度优先</a><a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/%E7%AE%97%E6%B3%95/1.htm">算法</a>
                        <div>1432-【基础】走出迷宫的最少步数题目描述一个迷宫由R行C列格子组成,有的格子里有障碍物,不能走;有的格子是空地,可以走。给定一个迷宫,求从左上角走到右下角最少需要走多少步(数据保证一定能走到)。只能在水平方向或垂直方向走,不能斜着走。输入第一行是两个整数,R和C,代表迷宫的行数和列数。(1usingnamespacestd;intn,m;chara[50][50];//地图intd[50][5</div>
                    </li>
                    <li><a href="/article/1834481258529386496.htm"
                           title="OJ2219左移右移(链表)——蓝桥杯2022年国赛" target="_blank">OJ2219左移右移(链表)——蓝桥杯2022年国赛</a>
                        <span class="text-muted">爱干饭的boy</span>
<a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%B8%8E%E7%AE%97%E6%B3%95%E9%A2%98%E7%9B%AE/1.htm">数据结构与算法题目</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/1.htm">数据结构</a><a class="tag" taget="_blank" href="/search/%E7%AE%97%E6%B3%95/1.htm">算法</a>
                        <div>代码为(双向链表):#includeusingnamespacestd;structlink{intdata;link*prev;link*next;};intmain(){intn,m;cin>>n>>m;link*l=newlink();//创建头节点,不存储实际数据,仅作为起始点link*tail=l;//尾指针初始指向头节点unordered_maph;//哈希表,用于快速查找任何节点fo</div>
                    </li>
                    <li><a href="/article/1834348018132938752.htm"
                           title="蓝桥杯备赛day01:循环" target="_blank">蓝桥杯备赛day01:循环</a>
                        <span class="text-muted">小西yu</span>
<a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF2025%E5%A4%87%E8%B5%9B/1.htm">蓝桥杯2025备赛</a><a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/c%2B%2B/1.htm">c++</a>
                        <div>这类题目较为简单,就不写解析了,提供三种语言的参考代码,欢迎在评论区讨论!分离整数的各个位数#includeusingnamespacestd;intmain(){intn;cin>>n;while(n>0){cout0:print(n%10,end='')n=n//10importjava.util.Scanner;publicclassMain{publicstaticvoidmain(Str</div>
                    </li>
                    <li><a href="/article/1834118346061213696.htm"
                           title="陕西赛区 蓝桥杯 Java b组 冲省一 每日一敲 第二天(苦涩。。" target="_blank">陕西赛区 蓝桥杯 Java b组 冲省一 每日一敲 第二天(苦涩。。</a>
                        <span class="text-muted">hhXx_琉璃</span>
<a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/%E7%AE%97%E6%B3%95/1.htm">算法</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a>
                        <div>蓝桥杯2023年第十四届省赛真题-数组分割时间限制:3s内存限制:576MB提交:1353解决:279题目描述小蓝有一个长度为N的数组A=[A0,A1,...,AN−1]。现在小蓝想要从A对应的数组下标所构成的集合I={0,1,2,...,N−1}中找出一个子集R1,那么R1在I中的补集为R2。记S1=∑r∈R1Ar,S2=∑r∈R2Ar,我们要求S1和S2均为偶数,请问在这种情况下共有多少种不同</div>
                    </li>
                    <li><a href="/article/1833873147242311680.htm"
                           title="蓝桥杯1.确定字符串是否包含唯一字符" target="_blank">蓝桥杯1.确定字符串是否包含唯一字符</a>
                        <span class="text-muted">DANGAOGAO</span>
<a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a>
                        <div>插播一句,博主转学python了,来写写算法题,若掌握好会考虑捐300块。题目:题目描述实现一个算法来识别一个字符串的字符是否是唯一的(忽略字母大小写)。若唯一,则输出YES,否则输出NO。输入描述输入一行字符串,长度不超过100。输出描述输出一行,若字符串的字符是唯一的,则输出YES,否则输出NO。输入输出样例示例输入abd25+输出YESimportosimportsysa=input()a=</div>
                    </li>
                    <li><a href="/article/1833873147951149056.htm"
                           title="蓝桥杯2. 确定字符串是否是另一个的排列" target="_blank">蓝桥杯2. 确定字符串是否是另一个的排列</a>
                        <span class="text-muted">DANGAOGAO</span>
<a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a>
                        <div>题目描述实现一个算法来识别一个字符串str2str2是否是另一个字符串str1str1的排列。排列的解释如下:如果将str1str1的字符拆分开,重新排列后再拼接起来,能够得到str2str2,那么就说字符串str2str2是字符串str1str1的排列。(不忽略大小写)如果str2str2字符串是str1str1字符串的排列,则输出YES;如果str2str2字符串不是str1str1字符串的排</div>
                    </li>
                    <li><a href="/article/1833873148584488960.htm"
                           title="蓝桥杯3. 压缩字符串" target="_blank">蓝桥杯3. 压缩字符串</a>
                        <span class="text-muted">DANGAOGAO</span>
<a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a>
                        <div>题目描述实现一个算法来压缩一个字符串。压缩的要求如下:需要判断压缩能不能节省空间,仅在压缩后字符串比原字符串长度更短时进行压缩。压缩的格式是将连续相同字符替换为字符+数字形式,例如"AAABCCDDDD"变为"A3BC2D4"。输入描述输入一行字符串,长度不超过500.输出描述输出一行。若输入的字符串可压缩,则输出压缩后的字符串,否则输出NO。输入输出样例示例输入AAABCCDDDD输出A3BC2</div>
                    </li>
                    <li><a href="/article/1833588214707875840.htm"
                           title="【笔试题汇总】华为春招笔试题题解 2024-3-20" target="_blank">【笔试题汇总】华为春招笔试题题解 2024-3-20</a>
                        <span class="text-muted">PXM的算法星球</span>
<a class="tag" taget="_blank" href="/search/%E5%A4%A7%E5%8E%82%E9%9D%A2%E8%AF%95%E9%A2%98/1.htm">大厂面试题</a><a class="tag" taget="_blank" href="/search/%E5%8D%8E%E4%B8%BA/1.htm">华为</a><a class="tag" taget="_blank" href="/search/%E9%9D%A2%E8%AF%95/1.htm">面试</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/1.htm">数据结构</a><a class="tag" taget="_blank" href="/search/%E7%AE%97%E6%B3%95/1.htm">算法</a>
                        <div>这里是paoxiaomo,一个现役ACMer,之后将会持续更新算法笔记系列以及笔试题题解系列本文章面向想打ICPC/蓝桥杯/天梯赛等程序设计竞赛,以及各个大厂笔试的选手感谢大家的订阅➕和喜欢有什么想看的算法专题可以私信博主(本文题面由清隆学长收集)01.K小姐的魔法药水问题描述K小姐是一位魔法师,她最近在研究一种神奇的魔法药水。这种药水由一系列魔法材料制成,每种材料都有一个正整数的魔法值。K小姐按</div>
                    </li>
                    <li><a href="/article/1833497825984475136.htm"
                           title="C++刷题开关灯——蓝桥杯备战D7" target="_blank">C++刷题开关灯——蓝桥杯备战D7</a>
                        <span class="text-muted">一杯冰镇过的杨梅汁呐</span>
<a class="tag" taget="_blank" href="/search/c%2B%2B/1.htm">c++</a><a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/%E7%AE%97%E6%B3%95/1.htm">算法</a>
                        <div>解法一:解析一下题目对编号为K的倍数的灯进行操作——这些灯都有一个K因子初始灯的状态为开启,最后灯的状态为关闭——进行了奇数次操作一次操作——一个因子所求的灯需有奇数次操作——这些灯都有奇数个因子所以,我们的解决办法显而易见,找出1~N范围内因子个数为奇数的编号。#include#includeusingnamespacestd;intmain(){vectorresult;intN=0;cin></div>
                    </li>
                    <li><a href="/article/1833062337695805440.htm"
                           title="扫雷(蓝桥杯)" target="_blank">扫雷(蓝桥杯)</a>
                        <span class="text-muted">DHX~</span>
<a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/%E7%AE%97%E6%B3%95/1.htm">算法</a>
                        <div>题目描述小明最近迷上了一款名为《扫雷》的游戏。其中有一个关卡的任务如下,在一个二维平面上放置着n个炸雷,第i个炸雷(xi,yi,ri)表示在坐标(xi,yi)处存在一个炸雷,它的爆炸范围是以半径为ri的一个圆。为了顺利通过这片土地,需要玩家进行排雷。玩家可以发射m个排雷火箭,小明已经规划好了每个排雷火箭的发射方向,第j个排雷火箭(xj,yj,rj)表示这个排雷火箭将会在(xj,yj)处爆炸,它的爆</div>
                    </li>
                    <li><a href="/article/1833027287977652224.htm"
                           title="蓝桥杯,嵌入式,物联网,串口接收中断加空闲中断,最简单实用的方法_空闲中断和接收中断" target="_blank">蓝桥杯,嵌入式,物联网,串口接收中断加空闲中断,最简单实用的方法_空闲中断和接收中断</a>
                        <span class="text-muted">2401_84009773</span>
<a class="tag" taget="_blank" href="/search/%E7%A8%8B%E5%BA%8F%E5%91%98/1.htm">程序员</a><a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/%E7%89%A9%E8%81%94%E7%BD%91/1.htm">物联网</a><a class="tag" taget="_blank" href="/search/%E8%81%8C%E5%9C%BA%E5%92%8C%E5%8F%91%E5%B1%95/1.htm">职场和发展</a>
                        <div>文章目录前言一、串口的空闲中断?二、使用步骤1.打开串口中断(空闲中断加接受中断)2.中断服务函数总结文章目录前言一、串口的空闲中断是什么?二、使用步骤1.引入库2.读入数据总结前言之所以写这篇文章,是因为参加蓝桥杯的时候发现HAL库的串口很难用,以至于串口总是接收都有问题。这篇文章还适合刚刚使用HAL库,回调函数用不习惯的同学,本文章以物联网L071为例来写,嵌入式G431也同样适用。一、串口的</div>
                    </li>
                    <li><a href="/article/1832949386083135488.htm"
                           title="【Java】第十五届蓝桥杯JavaB组第一道填空题" target="_blank">【Java】第十五届蓝桥杯JavaB组第一道填空题</a>
                        <span class="text-muted">寸 铁</span>
<a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF%E4%B8%8A%E5%B2%B8/1.htm">蓝桥杯上岸</a><a class="tag" taget="_blank" href="/search/%E6%AF%8F%E6%97%A5%E4%B8%80%E9%A2%98/1.htm">每日一题</a><a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a>
                        <div>【Java】2024年第十五届蓝桥杯JavaB组第一道填空题大家好我是寸铁总结了一篇【Java】第十五届蓝桥杯JavaB组第一道填空题文章喜欢的小伙伴可以点点关注更多蓝桥杯文章详见专栏JavaB组第一道填空题题解如下:看到这里的小伙伴,恭喜你又掌握了一个技能希望大家能取得胜利,坚持就是胜利我是寸铁!我们下期再见往期好文保姆级教程【保姆级教程】Windows11下go-zero的etcd安装与初步使</div>
                    </li>
                    <li><a href="/article/1831768267425935360.htm"
                           title="蓝桥杯Python青少组中/高级国赛真题解析(2023年5月)" target="_blank">蓝桥杯Python青少组中/高级国赛真题解析(2023年5月)</a>
                        <span class="text-muted">小芋头的初码农</span>
<a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E5%89%8D%E7%AB%AF/1.htm">前端</a>
                        <div>第1题以下选项中,哪一个可以将字典dict1与字典dict2合并?()A.dict1.add(dict2)B.dict1.extend(dict2)C.dict1.update(dict2)D.dict1.merge(dict2)【答案】:C【解析】字典没有add和extend函数,列表有add和extend函数。merge是pandas中的内置函数。字典使用update将两个字典进行合并,故选C</div>
                    </li>
                    <li><a href="/article/1831768267836977152.htm"
                           title="青少年蓝桥杯国赛要点" target="_blank">青少年蓝桥杯国赛要点</a>
                        <span class="text-muted">小芋头的初码农</span>
<a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/%E8%81%8C%E5%9C%BA%E5%92%8C%E5%8F%91%E5%B1%95/1.htm">职场和发展</a>
                        <div>1.字典的常见方法dict——{key:value,}Python3字典删除操作:删除键:deldicto['key']删除键对应的值:dicto.pop(key)(2022.05出现在选择题第三题)清空字典:dicto.clear()删除字典:deldicto返回并删除字典中最后一个键值对:dicto.popitem()更新操作:将字典1与字典2合并在一起,也叫将字典2的数据更新到字典1中:di</div>
                    </li>
                    <li><a href="/article/1831768141135441920.htm"
                           title="第十五届蓝桥杯大赛青少组——赛前解析(算法)" target="_blank">第十五届蓝桥杯大赛青少组——赛前解析(算法)</a>
                        <span class="text-muted">小芋头的初码农</span>
<a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/%E7%AE%97%E6%B3%95/1.htm">算法</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a>
                        <div>算法:进制转换、模拟算法,枚举算法,冒泡排序,插入排序,选择排序,递推算法,递归算法,贪心算法。1.进制转换二进制:只包含0和1八进制:只包含0-7十进制:只包含0-9十六进制:只包含0-9和‘A’-‘F’十进制转二进制、八进制、十六进制十进制数a=5二进制b=bin(a);八进制c=oct(a);十六进制d=hex(a)二进制转十进制、八进制、十六进制二进制数a=‘101010’十进制b=int</div>
                    </li>
                    <li><a href="/article/1831768014735896576.htm"
                           title="第十四届青少年蓝桥杯python组省赛真题" target="_blank">第十四届青少年蓝桥杯python组省赛真题</a>
                        <span class="text-muted">小芋头的初码农</span>
<a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a><a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a>
                        <div>单选题1.执行以下代码,输出结果是(A)。age={16,18,7}print(type(sorted(age))A.B.C.D.2.执行以下代码,输出结果是(A)。lst=”abc”print(lst+lst)A.abcabcB.abcC.lst+lstD.abc+abc3.已知ls=[3.5,”Python”,[10,“LIST”],3.6],那么ls[2][-1][1]的运行结果是?(A).</div>
                    </li>
                    <li><a href="/article/1831758686918373376.htm"
                           title="第15届蓝桥杯Python青少组选拔赛(STEMA)2023年8月真题-附答案" target="_blank">第15届蓝桥杯Python青少组选拔赛(STEMA)2023年8月真题-附答案</a>
                        <span class="text-muted">伶俐角少儿编程</span>
<a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/%E7%AE%97%E6%B3%95/1.htm">算法</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E9%9D%92%E5%B0%91%E5%B9%B4%E7%BC%96%E7%A8%8B/1.htm">青少年编程</a><a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a>
                        <div>第15届蓝桥杯Python青少组选拔赛(STEMA)2023年8月真题题目总数:11总分数:400真题下载点我百度网盘https://pan.baidu.com/s/1JRLLwW2C-OBbcY2tJ3uYJg?pwd=2wk2一、单选题第1题单选题以下不符合Python语言变量命名规则的是()。A.kB.2_kC._kD.ok答案B第2题单选题已知:s=python,执行print(s[-1]</div>
                    </li>
                    <li><a href="/article/1831747460335235072.htm"
                           title="第十三届蓝桥杯大赛青少组——中级组python真题" target="_blank">第十三届蓝桥杯大赛青少组——中级组python真题</a>
                        <span class="text-muted">小芋头的初码农</span>
<a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E7%AE%97%E6%B3%95/1.htm">算法</a>
                        <div>第1题单选题下列关于函数的说法正确的是()。A.函数的定义必须在程序的开头B.函数定义后,其中的程序就可以自动执行C.函数定义后需要调用才会执行D.函数体与关键字def必须左对齐解析:python中函数定义在调用后才会执行,其他都错的,选C第2题单选题十进制数55转换成十六进制是()。A.110111B.313C.37D.67解析:55%16=7,55//16=3因此转换为16进制后为37选C,第</div>
                    </li>
                    <li><a href="/article/1831570594945134592.htm"
                           title="注意啦!第15届蓝桥杯青少组大赛账号8月1日开启注册" target="_blank">注意啦!第15届蓝桥杯青少组大赛账号8月1日开启注册</a>
                        <span class="text-muted">@小码农</span>
<a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/%E8%81%8C%E5%9C%BA%E5%92%8C%E5%8F%91%E5%B1%95/1.htm">职场和发展</a>
                        <div>2024年第十五届蓝桥杯大赛青少组即将在8月24日开启,今天蓝桥杯青少组官网发布了账号注册通知,注册时间:2024年8月1日13:00至8月4日13:00截止。账号注册为个人账号,仅限本人(法定监护人),不开放团体账号。在之前,蓝桥杯青少组官网发布了通知,第十五蓝桥杯青少组比赛将在8月24日开启。关于第十五届蓝桥杯大赛青少组账号注册通知各参赛选手:第十五届蓝桥杯全国软件和信息技术专业人才大赛青少组</div>
                    </li>
                    <li><a href="/article/1831053005160542208.htm"
                           title="【蓝桥杯青少组】第十五届省赛python(2024)" target="_blank">【蓝桥杯青少组】第十五届省赛python(2024)</a>
                        <span class="text-muted">jikuibu2023</span>
<a class="tag" taget="_blank" href="/search/%E5%A4%87%E6%88%98%E8%93%9D%E5%B0%91/1.htm">备战蓝少</a><a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/%E9%9D%92%E5%B0%91%E5%B9%B4%E7%BC%96%E7%A8%8B/1.htm">青少年编程</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a>
                        <div>选择题做得飞快。编程题被绊住了...第四题熟悉等差数列求和公式即可,无需赘述第五题果然是贪心算法,之前强化训练了一天,看来效果还是不够。题目简述浇水n棵植物编号i=1-n,所需浇水w[i]每次连续浇L棵,每棵1份水,重复浇多余的排水。问,最少需要浇多少次,共排水多少量?输入:n=4;L=3;w=[1,1,3,2]输出3,2思路贪心算法#先找到最高max(w)#再算前后L个范围内连续L个w[j]之和</div>
                    </li>
                    <li><a href="/article/1830999948389347328.htm"
                           title="2024年第十五届蓝桥杯Java B组参赛心得" target="_blank">2024年第十五届蓝桥杯Java B组参赛心得</a>
                        <span class="text-muted">Cloudcver.面向木白yu</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/%E7%AE%97%E6%B3%95/1.htm">算法</a>
                        <div>浅浅记录一下大学第一次极大概率也是最后一次蓝桥杯...先说结果:十五届JavaB组河南赛区省二(虽然有点小菜,毕竟第一次参加经验啥的有所欠缺,结果差强人意还能接受)目前省赛原题官网似乎还没有出,需要看题目和AK题解的宝子可以点下方这里移步小破站官网出的话我再来更新^-^(个人觉得这个阿婆主讲的还不戳~当然如果能搜到更好的更官方的题解也都可以参考)B站——十五届蓝桥杯JavaB组AK题解视频十五届蓝</div>
                    </li>
                    <li><a href="/article/1830659105631596544.htm"
                           title="蓝桥杯 第六天 全排列和其他库函数" target="_blank">蓝桥杯 第六天 全排列和其他库函数</a>
                        <span class="text-muted">sheansavage</span>
<a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/%E8%81%8C%E5%9C%BA%E5%92%8C%E5%8F%91%E5%B1%95/1.htm">职场和发展</a>
                        <div>目录1.全排列1.1.next_permutation()函数1.2.prev_permutation()函数2.其他库函数2.1.memset()2.2.swap()2.3.reverse()2.4.unique()1.全排列1.1.next_permutation()函数next_permutation函数用于生成当前序列的下一个排列.它按照字典对序列进行重新排列,如果存在下一个排序,则将当前</div>
                    </li>
                    <li><a href="/article/1830432621864251392.htm"
                           title="【第十三届蓝桥杯单片机国赛满分代码】" target="_blank">【第十三届蓝桥杯单片机国赛满分代码】</a>
                        <span class="text-muted">代码能跑就可以</span>
<a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF%E5%8D%95%E7%89%87%E6%9C%BA%E7%AB%9E%E8%B5%9B/1.htm">蓝桥杯单片机竞赛</a><a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/%E5%8D%95%E7%89%87%E6%9C%BA/1.htm">单片机</a><a class="tag" taget="_blank" href="/search/%E8%81%8C%E5%9C%BA%E5%92%8C%E5%8F%91%E5%B1%95/1.htm">职场和发展</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a><a class="tag" taget="_blank" href="/search/%E7%AC%94%E8%AE%B0/1.htm">笔记</a><a class="tag" taget="_blank" href="/search/%E5%B5%8C%E5%85%A5%E5%BC%8F%E7%A1%AC%E4%BB%B6/1.htm">嵌入式硬件</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a>
                        <div>其他相关文章:【提分必看!】蓝桥杯单片机提分技巧(国一经验分享)【国一超全代码分享!】蓝桥杯单片机各模块代码整合【蓝桥杯单片机客观题知识点汇总】本代码经过编译后生成的hex文件经过了4T测试平台的满分测试。读者对代码有疑问的可以在评论区里提出。主函数#include"stdio.h"#include"intrins.h"#include"bsp_init.h"#include"bsp_led.h"</div>
                    </li>
                    <li><a href="/article/1830228049619152896.htm"
                           title="题解:P11001 [蓝桥杯 2024 省 Python B] 连连看" target="_blank">题解:P11001 [蓝桥杯 2024 省 Python B] 连连看</a>
                        <span class="text-muted">andycode_</span>
<a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/%E7%AE%97%E6%B3%95/1.htm">算法</a>
                        <div>题目传送门洛谷题解虽然这是一道Python题,但我还是忍不住写了一个C++题解。思路讲解仔细读题,不难发现。如果∣a−c∣=∣b−d∣>0|a-c|=|b-d|>0∣a−c∣=∣b−d∣>0,则说明Aa,bA_{a,b}Aa,b与Ac,dA_{c,d}Ac,d同处一条对角线,且不是同一个点。而要使Aa,bA_{a,b}Aa,b和Ac,dA_{c,d}Ac,d在同一条对角线上,要么a−b=c−da-</div>
                    </li>
                    <li><a href="/article/1829596242422886400.htm"
                           title="【冲刺蓝桥杯的最后30天】day3" target="_blank">【冲刺蓝桥杯的最后30天】day3</a>
                        <span class="text-muted">想要慢慢变得优秀的向阳同学</span>
<a class="tag" taget="_blank" href="/search/%E5%A4%87%E6%88%98%E8%93%9D%E6%A1%A5%E6%9D%AF30%E5%A4%A9/1.htm">备战蓝桥杯30天</a><a class="tag" taget="_blank" href="/search/Java/1.htm">Java</a><a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/%E7%AE%97%E6%B3%95/1.htm">算法</a>
                        <div>大家好,我是想要慢慢变得优秀的向阳同学‍,断更了整整一年,又开始恢复CSDN更新,从今天开始更新备战蓝桥30天系列,一共30天,如果对你有帮助或者正在备战蓝桥杯的小伙伴可以支持一下哦!~不能说肯定是干货,但会让你有所收获!今天满课,学的有点脑子混沌,就少量更新两道题,以后会补上的,见谅见谅我们总是在生活扮演各种角色,却唯独很少扮演自己门牌制作-蓝桥云课(lanqiao.cn)一道暴力就可以解决的模</div>
                    </li>
                    <li><a href="/article/1829593467253256192.htm"
                           title="【蓝桥杯冲刺省一,省一看这些就够了-Java版本】蓝桥杯字符串问题相关模板以及练习题" target="_blank">【蓝桥杯冲刺省一,省一看这些就够了-Java版本】蓝桥杯字符串问题相关模板以及练习题</a>
                        <span class="text-muted">Dashcoding编程设</span>
<a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/%E8%81%8C%E5%9C%BA%E5%92%8C%E5%8F%91%E5%B1%95/1.htm">职场和发展</a><a class="tag" taget="_blank" href="/search/%E5%AD%97%E7%AC%A6%E4%B8%B2/1.htm">字符串</a><a class="tag" taget="_blank" href="/search/%E7%AE%97%E6%B3%95/1.htm">算法</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/1.htm">数据结构</a><a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF%E7%9C%81%E4%B8%80/1.htm">蓝桥杯省一</a>
                        <div>蓝桥杯历年省赛真题点击链接免费加入题单字符串常见字符串函数与reversepublicclassStringExamples{publicstaticvoidmain(String[]args){//示例字符串Stringstr="Hello,World!";//1.length()方法System.out.println("Lengthofthestring:"+str.length());//</div>
                    </li>
                    <li><a href="/article/1829592332773715968.htm"
                           title="冲刺蓝桥杯第一章输入与输出" target="_blank">冲刺蓝桥杯第一章输入与输出</a>
                        <span class="text-muted">CodeWizard~</span>
<a class="tag" taget="_blank" href="/search/%E7%BC%96%E7%A8%8B%E5%BE%81%E9%80%94%C2%B7%E8%93%9D%E6%A1%A5%E9%A3%8E%E4%BA%91%E5%BD%95/1.htm">编程征途·蓝桥风云录</a><a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/%E8%81%8C%E5%9C%BA%E5%92%8C%E5%8F%91%E5%B1%95/1.htm">职场和发展</a><a class="tag" taget="_blank" href="/search/%E7%AE%97%E6%B3%95/1.htm">算法</a><a class="tag" taget="_blank" href="/search/c%2B%2B/1.htm">c++</a>
                        <div>取消同步流加速cin/cout运行时间cin与cout是C++提供的函数输入输出方便但速度较慢,所以需要用指令进行输入输出加速,切记使用加速命令后不要同时使用cin/cout与scanf/printf。ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);scanf与printf其实是C语言提供的函数。大多数情况下,它们的速度比cin和cout更快,并且能够</div>
                    </li>
                    <li><a href="/article/1829592333700657152.htm"
                           title="冲刺蓝桥杯第四章标准模版库STL(上)" target="_blank">冲刺蓝桥杯第四章标准模版库STL(上)</a>
                        <span class="text-muted">CodeWizard~</span>
<a class="tag" taget="_blank" href="/search/%E7%BC%96%E7%A8%8B%E5%BE%81%E9%80%94%C2%B7%E8%93%9D%E6%A1%A5%E9%A3%8E%E4%BA%91%E5%BD%95/1.htm">编程征途·蓝桥风云录</a><a class="tag" taget="_blank" href="/search/%E8%93%9D%E6%A1%A5%E6%9D%AF/1.htm">蓝桥杯</a><a class="tag" taget="_blank" href="/search/c%2B%2B/1.htm">c++</a><a class="tag" taget="_blank" href="/search/%E7%AE%97%E6%B3%95/1.htm">算法</a><a class="tag" taget="_blank" href="/search/%E8%81%8C%E5%9C%BA%E5%92%8C%E5%8F%91%E5%B1%95/1.htm">职场和发展</a>
                        <div>vector:介绍:vector是C++标准模板库(STL)中的一个非常重要的序列容器,它封装了动态数组的实现。vector能够存储具有相同类型的元素序列,并且能够根据需要自动调整其大小。注意:在局部区域中(比如局部函数里面)开vector数组,是在堆空间里面开的。在局部区域开数组是在栈空间开的,而栈空间比较小,如果开了非常长的数组就会发生爆栈。故局部区域不可以开大长度数组,但是可以开大长度vec</div>
                    </li>
                                <li><a href="/article/45.htm"
                                       title="安装数据库首次应用" target="_blank">安装数据库首次应用</a>
                                    <span class="text-muted">Array_06</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/oracle/1.htm">oracle</a><a class="tag" taget="_blank" href="/search/sql/1.htm">sql</a>
                                    <div>可是为什么再一次失败之后就变成直接跳过那个要求 
enter full pathname of java.exe的界面 
 
 
这个java.exe是你的Oracle 11g安装目录中例如:【F:\app\chen\product\11.2.0\dbhome_1\jdk\jre\bin】下的java.exe 。不是你的电脑安装的java jdk下的java.exe! 
注意第一次,使用SQL D</div>
                                </li>
                                <li><a href="/article/172.htm"
                                       title="Weblogic Server Console密码修改和遗忘解决方法" target="_blank">Weblogic Server Console密码修改和遗忘解决方法</a>
                                    <span class="text-muted">bijian1013</span>
<a class="tag" taget="_blank" href="/search/Welogic/1.htm">Welogic</a>
                                    <div>        在工作中一同事将Weblogic的console的密码忘记了,通过网上查询资料解决,实践整理了一下。 
一.修改Console密码 
        打开weblogic控制台,安全领域 --> myrealm -->&n</div>
                                </li>
                                <li><a href="/article/299.htm"
                                       title="IllegalStateException: Cannot forward a response that is already committed" target="_blank">IllegalStateException: Cannot forward a response that is already committed</a>
                                    <span class="text-muted">Cwind</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/Servlets/1.htm">Servlets</a>
                                    <div>对于初学者来说,一个常见的误解是:当调用 forward() 或者 sendRedirect() 时控制流将会自动跳出原函数。标题所示错误通常是基于此误解而引起的。   示例代码:   
protected void doPost() {
    if (someCondition) {
        sendRedirect();
    }
    forward(); // Thi</div>
                                </li>
                                <li><a href="/article/426.htm"
                                       title="基于流的装饰设计模式" target="_blank">基于流的装饰设计模式</a>
                                    <span class="text-muted">木zi_鸣</span>
<a class="tag" taget="_blank" href="/search/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/1.htm">设计模式</a>
                                    <div>当想要对已有类的对象进行功能增强时,可以定义一个类,将已有对象传入,基于已有的功能,并提供加强功能。 
自定义的类成为装饰类 
 
模仿BufferedReader,对Reader进行包装,体现装饰设计模式 
 
装饰类通常会通过构造方法接受被装饰的对象,并基于被装饰的对象功能,提供更强的功能。 
装饰模式比继承灵活,避免继承臃肿,降低了类与类之间的关系 
 
装饰类因为增强已有对象,具备的功能该</div>
                                </li>
                                <li><a href="/article/553.htm"
                                       title="Linux中的uniq命令" target="_blank">Linux中的uniq命令</a>
                                    <span class="text-muted">被触发</span>
<a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a>
                                    <div>Linux命令uniq的作用是过滤重复部分显示文件内容,这个命令读取输入文件,并比较相邻的行。在正常情 况下,第二个及以后更多个重复行将被删去,行比较是根据所用字符集的排序序列进行的。该命令加工后的结果写到输出文件中。输入文件和输出文件必须不同。如 果输入文件用“- ”表示,则从标准输入读取。 
AD: 
uniq [选项] 文件 
说明:这个命令读取输入文件,并比较相邻的行。在正常情况下,第二个</div>
                                </li>
                                <li><a href="/article/680.htm"
                                       title="正则表达式Pattern" target="_blank">正则表达式Pattern</a>
                                    <span class="text-muted">肆无忌惮_</span>
<a class="tag" taget="_blank" href="/search/Pattern/1.htm">Pattern</a>
                                    <div>正则表达式是符合一定规则的表达式,用来专门操作字符串,对字符创进行匹配,切割,替换,获取。 
  
例如,我们需要对QQ号码格式进行检验 
规则是长度6~12位  不能0开头  只能是数字,我们可以一位一位进行比较,利用parseLong进行判断,或者是用正则表达式来匹配[1-9][0-9]{4,14} 或者 [1-9]\d{4,14} 
&nbs</div>
                                </li>
                                <li><a href="/article/807.htm"
                                       title="Oracle高级查询之OVER (PARTITION BY ..)" target="_blank">Oracle高级查询之OVER (PARTITION BY ..)</a>
                                    <span class="text-muted">知了ing</span>
<a class="tag" taget="_blank" href="/search/oracle/1.htm">oracle</a><a class="tag" taget="_blank" href="/search/sql/1.htm">sql</a>
                                    <div>一、rank()/dense_rank() over(partition by ...order by ...) 
 
现在客户有这样一个需求,查询每个部门工资最高的雇员的信息,相信有一定oracle应用知识的同学都能写出下面的SQL语句: 
 
 select e.ename, e.job, e.sal, e.deptno  
  from scott.emp e,  
       (se</div>
                                </li>
                                <li><a href="/article/934.htm"
                                       title="Python调试" target="_blank">Python调试</a>
                                    <span class="text-muted">矮蛋蛋</span>
<a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/pdb/1.htm">pdb</a>
                                    <div>原文地址: 
http://blog.csdn.net/xuyuefei1988/article/details/19399137 
1、下面网上收罗的资料初学者应该够用了,但对比IBM的Python 代码调试技巧: 
 
IBM:包括 pdb 模块、利用 PyDev 和 Eclipse 集成进行调试、PyCharm 以及 Debug 日志进行调试: 
 
http://www.ibm.com/d</div>
                                </li>
                                <li><a href="/article/1061.htm"
                                       title="webservice传递自定义对象时函数为空,以及boolean不对应的问题" target="_blank">webservice传递自定义对象时函数为空,以及boolean不对应的问题</a>
                                    <span class="text-muted">alleni123</span>
<a class="tag" taget="_blank" href="/search/webservice/1.htm">webservice</a>
                                    <div>今天在客户端调用方法 
NodeStatus status=iservice.getNodeStatus(). 
 
结果NodeStatus的属性都是null。 
 
进行debug之后,发现服务器端返回的确实是有值的对象。 
 
后来发现原来是因为在客户端,NodeStatus的setter全部被我删除了。 
本来是因为逻辑上不需要在客户端使用setter, 结果改了之后竟然不能获取带属性值的</div>
                                </li>
                                <li><a href="/article/1188.htm"
                                       title="java如何干掉指针,又如何巧妙的通过引用来操作指针————>说的就是java指针" target="_blank">java如何干掉指针,又如何巧妙的通过引用来操作指针————>说的就是java指针</a>
                                    <span class="text-muted">百合不是茶</span>

                                    <div>C语言的强大在于可以直接操作指针的地址,通过改变指针的地址指向来达到更改地址的目的,又是由于c语言的指针过于强大,初学者很难掌握, java的出现解决了c,c++中指针的问题 java将指针封装在底层,开发人员是不能够去操作指针的地址,但是可以通过引用来间接的操作: 
  
定义一个指针p来指向a的地址(&是地址符号): 
        </div>
                                </li>
                                <li><a href="/article/1315.htm"
                                       title="Eclipse打不开,提示“An error has occurred.See the log file ***/.log”" target="_blank">Eclipse打不开,提示“An error has occurred.See the log file ***/.log”</a>
                                    <span class="text-muted">bijian1013</span>
<a class="tag" taget="_blank" href="/search/eclipse/1.htm">eclipse</a>
                                    <div>打开eclipse工作目录的\.metadata\.log文件,发现如下错误: 
 
!ENTRY org.eclipse.osgi 4 0 2012-09-10 09:28:57.139 
!MESSAGE Application error 
!STACK 1 
java.lang.NoClassDefFoundError: org/eclipse/core/resources/IContai</div>
                                </li>
                                <li><a href="/article/1442.htm"
                                       title="spring aop实例annotation方法实现" target="_blank">spring aop实例annotation方法实现</a>
                                    <span class="text-muted">bijian1013</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/spring/1.htm">spring</a><a class="tag" taget="_blank" href="/search/AOP/1.htm">AOP</a><a class="tag" taget="_blank" href="/search/annotation/1.htm">annotation</a>
                                    <div>        在spring aop实例中我们通过配置xml文件来实现AOP,这里学习使用annotation来实现,使用annotation其实就是指明具体的aspect,pointcut和advice。1.申明一个切面(用一个类来实现)在这个切面里,包括了advice和pointcut 
AdviceMethods.jav</div>
                                </li>
                                <li><a href="/article/1569.htm"
                                       title="[Velocity一]Velocity语法基础入门" target="_blank">[Velocity一]Velocity语法基础入门</a>
                                    <span class="text-muted">bit1129</span>
<a class="tag" taget="_blank" href="/search/velocity/1.htm">velocity</a>
                                    <div>用户和开发人员参考文档 
http://velocity.apache.org/engine/releases/velocity-1.7/developer-guide.html 
  注释 
1.行级注释## 
2.多行注释#*  *# 
  变量定义 
使用$开头的字符串是变量定义,例如$var1, $var2, 
  赋值 
使用#set为变量赋值,例</div>
                                </li>
                                <li><a href="/article/1696.htm"
                                       title="【Kafka十一】关于Kafka的副本管理" target="_blank">【Kafka十一】关于Kafka的副本管理</a>
                                    <span class="text-muted">bit1129</span>
<a class="tag" taget="_blank" href="/search/kafka/1.htm">kafka</a>
                                    <div>1. 关于request.required.acks 
  
request.required.acks控制者Producer写请求的什么时候可以确认写成功,默认是0, 
0表示即不进行确认即返回。 
1表示Leader写成功即返回,此时还没有进行写数据同步到其它Follower Partition中 
-1表示根据指定的最少Partition确认后才返回,这个在 
  
Th</div>
                                </li>
                                <li><a href="/article/1823.htm"
                                       title="lua统计nginx内部变量数据" target="_blank">lua统计nginx内部变量数据</a>
                                    <span class="text-muted">ronin47</span>
<a class="tag" taget="_blank" href="/search/lua+nginx%E3%80%80+%E7%BB%9F%E8%AE%A1/1.htm">lua nginx  统计</a>
                                    <div>server {
    listen 80;
    server_name photo.domain.com;
    location /{set $str $uri;
        content_by_lua '
            local url = ngx.var.uri
            local res = ngx.location.capture(</div>
                                </li>
                                <li><a href="/article/1950.htm"
                                       title="java-11.二叉树中节点的最大距离" target="_blank">java-11.二叉树中节点的最大距离</a>
                                    <span class="text-muted">bylijinnan</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a>
                                    <div>
import java.util.ArrayList;
import java.util.List;


public class MaxLenInBinTree {

	/*
	 a.			1
	 		   /  \
	 		  2    3
	 		 / \  / \
	 		4   5 6  7
	 	max=4	pass "root"
	 </div>
                                </li>
                                <li><a href="/article/2077.htm"
                                       title="Netty源码学习-ReadTimeoutHandler" target="_blank">Netty源码学习-ReadTimeoutHandler</a>
                                    <span class="text-muted">bylijinnan</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/netty/1.htm">netty</a>
                                    <div> 
ReadTimeoutHandler的实现思路: 
开启一个定时任务,如果在指定时间内没有接收到消息,则抛出ReadTimeoutException 
这个异常的捕获,在开发中,交给跟在ReadTimeoutHandler后面的ChannelHandler,例如 
 
 

private final ChannelHandler timeoutHandler =
	new ReadTim</div>
                                </li>
                                <li><a href="/article/2204.htm"
                                       title="jquery验证上传文件样式及大小(好用)" target="_blank">jquery验证上传文件样式及大小(好用)</a>
                                    <span class="text-muted">cngolon</span>
<a class="tag" taget="_blank" href="/search/%E6%96%87%E4%BB%B6%E4%B8%8A%E4%BC%A0/1.htm">文件上传</a><a class="tag" taget="_blank" href="/search/jquery%E9%AA%8C%E8%AF%81/1.htm">jquery验证</a>
                                    <div><!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script src="jquery1.8/jquery-1.8.0.</div>
                                </li>
                                <li><a href="/article/2331.htm"
                                       title="浏览器兼容【转】" target="_blank">浏览器兼容【转】</a>
                                    <span class="text-muted">cuishikuan</span>
<a class="tag" taget="_blank" href="/search/css/1.htm">css</a><a class="tag" taget="_blank" href="/search/%E6%B5%8F%E8%A7%88%E5%99%A8/1.htm">浏览器</a><a class="tag" taget="_blank" href="/search/IE/1.htm">IE</a>
                                    <div>浏览器兼容问题一:不同浏览器的标签默认的外补丁和内补丁不同 
 
问题症状:随便写几个标签,不加样式控制的情况下,各自的margin 和padding差异较大。 
 
碰到频率:100% 
 
解决方案:CSS里    *{margin:0;padding:0;} 
 
备注:这个是最常见的也是最易解决的一个浏览器兼容性问题,几乎所有的CSS文件开头都会用通配符*来设</div>
                                </li>
                                <li><a href="/article/2458.htm"
                                       title="Shell特殊变量:Shell $0, $#, $*, $@, $?, $$和命令行参数" target="_blank">Shell特殊变量:Shell $0, $#, $*, $@, $?, $$和命令行参数</a>
                                    <span class="text-muted">daizj</span>
<a class="tag" taget="_blank" href="/search/shell/1.htm">shell</a><a class="tag" taget="_blank" href="/search/%24%23/1.htm">$#</a><a class="tag" taget="_blank" href="/search/%24%3F/1.htm">$?</a><a class="tag" taget="_blank" href="/search/%E7%89%B9%E6%AE%8A%E5%8F%98%E9%87%8F/1.htm">特殊变量</a>
                                    <div>前面已经讲到,变量名只能包含数字、字母和下划线,因为某些包含其他字符的变量有特殊含义,这样的变量被称为特殊变量。例如,$ 表示当前Shell进程的ID,即pid,看下面的代码:   
 
  $echo $$  
   
运行结果 
29949 
   特殊变量列表   变量 含义   $0 当前脚本的文件名   $n 传递给脚本或函数的参数。n 是一个数字,表示第几个参数。例如,第一个</div>
                                </li>
                                <li><a href="/article/2585.htm"
                                       title="程序设计KISS 原则-------KEEP IT SIMPLE, STUPID!" target="_blank">程序设计KISS 原则-------KEEP IT SIMPLE, STUPID!</a>
                                    <span class="text-muted">dcj3sjt126com</span>
<a class="tag" taget="_blank" href="/search/unix/1.htm">unix</a>
                                    <div>翻到一本书,讲到编程一般原则是kiss:Keep It Simple, Stupid.对这个原则深有体会,其实不仅编程如此,而且系统架构也是如此。 
 KEEP IT SIMPLE, STUPID! 编写只做一件事情,并且要做好的程序;编写可以在一起工作的程序,编写处理文本流的程序,因为这是通用的接口。这就是UNIX哲学.所有的哲学真 正的浓缩为一个铁一样的定律,高明的工程师的神圣的“KISS 原</div>
                                </li>
                                <li><a href="/article/2712.htm"
                                       title="android Activity间List传值" target="_blank">android Activity间List传值</a>
                                    <span class="text-muted">dcj3sjt126com</span>
<a class="tag" taget="_blank" href="/search/Activity/1.htm">Activity</a>
                                    <div>第一个Activity: 
import java.util.ArrayList;import java.util.HashMap;import java.util.List;import java.util.Map;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import a</div>
                                </li>
                                <li><a href="/article/2839.htm"
                                       title="tomcat 设置java虚拟机内存" target="_blank">tomcat 设置java虚拟机内存</a>
                                    <span class="text-muted">eksliang</span>
<a class="tag" taget="_blank" href="/search/tomcat+%E5%86%85%E5%AD%98%E8%AE%BE%E7%BD%AE/1.htm">tomcat 内存设置</a>
                                    <div>转载请出自出处:http://eksliang.iteye.com/blog/2117772 
http://eksliang.iteye.com/ 
常见的内存溢出有以下两种: 
java.lang.OutOfMemoryError: PermGen space  
java.lang.OutOfMemoryError: Java heap space 
  
------------</div>
                                </li>
                                <li><a href="/article/2966.htm"
                                       title="Android 数据库事务处理" target="_blank">Android 数据库事务处理</a>
                                    <span class="text-muted">gqdy365</span>
<a class="tag" taget="_blank" href="/search/android/1.htm">android</a>
                                    <div>使用SQLiteDatabase的beginTransaction()方法可以开启一个事务,程序执行到endTransaction() 方法时会检查事务的标志是否为成功,如果程序执行到endTransaction()之前调用了setTransactionSuccessful() 方法设置事务的标志为成功则提交事务,如果没有调用setTransactionSuccessful() 方法则回滚事务。事</div>
                                </li>
                                <li><a href="/article/3093.htm"
                                       title="Java 打开浏览器" target="_blank">Java 打开浏览器</a>
                                    <span class="text-muted">hw1287789687</span>
<a class="tag" taget="_blank" href="/search/%E6%89%93%E5%BC%80%E7%BD%91%E5%9D%80/1.htm">打开网址</a><a class="tag" taget="_blank" href="/search/open%E6%B5%8F%E8%A7%88%E5%99%A8/1.htm">open浏览器</a><a class="tag" taget="_blank" href="/search/open+browser/1.htm">open browser</a><a class="tag" taget="_blank" href="/search/%E6%89%93%E5%BC%80url/1.htm">打开url</a><a class="tag" taget="_blank" href="/search/%E6%89%93%E5%BC%80%E6%B5%8F%E8%A7%88%E5%99%A8/1.htm">打开浏览器</a>
                                    <div>使用java 语言如何打开浏览器呢? 
我们先研究下在cmd窗口中,如何打开网址 
使用IE 打开 
D:\software\bin>cmd /c start iexplore http://hw1287789687.iteye.com/blog/2153709 
使用火狐打开 
D:\software\bin>cmd /c start firefox http://hw1287789</div>
                                </li>
                                <li><a href="/article/3220.htm"
                                       title="ReplaceGoogleCDN:将 Google CDN 替换为国内的 Chrome 插件" target="_blank">ReplaceGoogleCDN:将 Google CDN 替换为国内的 Chrome 插件</a>
                                    <span class="text-muted">justjavac</span>
<a class="tag" taget="_blank" href="/search/chrome/1.htm">chrome</a><a class="tag" taget="_blank" href="/search/Google/1.htm">Google</a><a class="tag" taget="_blank" href="/search/google+api/1.htm">google api</a><a class="tag" taget="_blank" href="/search/chrome%E6%8F%92%E4%BB%B6/1.htm">chrome插件</a>
                                    <div>Chrome Web Store 安装地址: https://chrome.google.com/webstore/detail/replace-google-cdn/kpampjmfiopfpkkepbllemkibefkiice 
 
 由于众所周知的原因,只需替换一个域名就可以继续使用Google提供的前端公共库了。 同样,通过script标记引用这些资源,让网站访问速度瞬间提速吧</div>
                                </li>
                                <li><a href="/article/3347.htm"
                                       title="进程VS.线程" target="_blank">进程VS.线程</a>
                                    <span class="text-muted">m635674608</span>
<a class="tag" taget="_blank" href="/search/%E7%BA%BF%E7%A8%8B/1.htm">线程</a>
                                    <div>资料来源: 
http://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000/001397567993007df355a3394da48f0bf14960f0c78753f000 1、Apache最早就是采用多进程模式 2、IIS服务器默认采用多线程模式 3、多进程优缺点 优点: 
多进程模式最大</div>
                                </li>
                                <li><a href="/article/3474.htm"
                                       title="Linux下安装MemCached" target="_blank">Linux下安装MemCached</a>
                                    <span class="text-muted">字符串</span>
<a class="tag" taget="_blank" href="/search/memcached/1.htm">memcached</a>
                                    <div>前提准备:1. MemCached目前最新版本为:1.4.22,可以从官网下载到。2. MemCached依赖libevent,因此在安装MemCached之前需要先安装libevent。2.1 运行下面命令,查看系统是否已安装libevent。[root@SecurityCheck ~]# rpm -qa|grep libevent libevent-headers-1.4.13-4.el6.n</div>
                                </li>
                                <li><a href="/article/3601.htm"
                                       title="java设计模式之--jdk动态代理(实现aop编程)" target="_blank">java设计模式之--jdk动态代理(实现aop编程)</a>
                                    <span class="text-muted">Supanccy2013</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/DAO/1.htm">DAO</a><a class="tag" taget="_blank" href="/search/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/1.htm">设计模式</a><a class="tag" taget="_blank" href="/search/AOP/1.htm">AOP</a>
                                    <div>    与静态代理类对照的是动态代理类,动态代理类的字节码在程序运行时由Java反射机制动态生成,无需程序员手工编写它的源代码。动态代理类不仅简化了编程工作,而且提高了软件系统的可扩展性,因为Java 反射机制可以生成任意类型的动态代理类。java.lang.reflect 包中的Proxy类和InvocationHandler 接口提供了生成动态代理类的能力。 
&</div>
                                </li>
                                <li><a href="/article/3728.htm"
                                       title="Spring 4.2新特性-对java8默认方法(default method)定义Bean的支持" target="_blank">Spring 4.2新特性-对java8默认方法(default method)定义Bean的支持</a>
                                    <span class="text-muted">wiselyman</span>
<a class="tag" taget="_blank" href="/search/spring+4/1.htm">spring 4</a>
                                    <div>2.1 默认方法(default method) 
 
 java8引入了一个default medthod; 
 用来扩展已有的接口,在对已有接口的使用不产生任何影响的情况下,添加扩展 
 使用default关键字 
 Spring 4.2支持加载在默认方法里声明的bean 
  
2.2 
 
 将要被声明成bean的类 
  
public class DemoService {
    </div>
                                </li>
                </ul>
            </div>
        </div>
    </div>

<div>
    <div class="container">
        <div class="indexes">
            <strong>按字母分类:</strong>
            <a href="/tags/A/1.htm" target="_blank">A</a><a href="/tags/B/1.htm" target="_blank">B</a><a href="/tags/C/1.htm" target="_blank">C</a><a
                href="/tags/D/1.htm" target="_blank">D</a><a href="/tags/E/1.htm" target="_blank">E</a><a href="/tags/F/1.htm" target="_blank">F</a><a
                href="/tags/G/1.htm" target="_blank">G</a><a href="/tags/H/1.htm" target="_blank">H</a><a href="/tags/I/1.htm" target="_blank">I</a><a
                href="/tags/J/1.htm" target="_blank">J</a><a href="/tags/K/1.htm" target="_blank">K</a><a href="/tags/L/1.htm" target="_blank">L</a><a
                href="/tags/M/1.htm" target="_blank">M</a><a href="/tags/N/1.htm" target="_blank">N</a><a href="/tags/O/1.htm" target="_blank">O</a><a
                href="/tags/P/1.htm" target="_blank">P</a><a href="/tags/Q/1.htm" target="_blank">Q</a><a href="/tags/R/1.htm" target="_blank">R</a><a
                href="/tags/S/1.htm" target="_blank">S</a><a href="/tags/T/1.htm" target="_blank">T</a><a href="/tags/U/1.htm" target="_blank">U</a><a
                href="/tags/V/1.htm" target="_blank">V</a><a href="/tags/W/1.htm" target="_blank">W</a><a href="/tags/X/1.htm" target="_blank">X</a><a
                href="/tags/Y/1.htm" target="_blank">Y</a><a href="/tags/Z/1.htm" target="_blank">Z</a><a href="/tags/0/1.htm" target="_blank">其他</a>
        </div>
    </div>
</div>
<footer id="footer" class="mb30 mt30">
    <div class="container">
        <div class="footBglm">
            <a target="_blank" href="/">首页</a> -
            <a target="_blank" href="/custom/about.htm">关于我们</a> -
            <a target="_blank" href="/search/Java/1.htm">站内搜索</a> -
            <a target="_blank" href="/sitemap.txt">Sitemap</a> -
            <a target="_blank" href="/custom/delete.htm">侵权投诉</a>
        </div>
        <div class="copyright">版权所有 IT知识库 CopyRight © 2000-2050 E-COM-NET.COM , All Rights Reserved.
<!--            <a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">京ICP备09083238号</a><br>-->
        </div>
    </div>
</footer>
<!-- 代码高亮 -->
<script type="text/javascript" src="/static/syntaxhighlighter/scripts/shCore.js"></script>
<script type="text/javascript" src="/static/syntaxhighlighter/scripts/shLegacy.js"></script>
<script type="text/javascript" src="/static/syntaxhighlighter/scripts/shAutoloader.js"></script>
<link type="text/css" rel="stylesheet" href="/static/syntaxhighlighter/styles/shCoreDefault.css"/>
<script type="text/javascript" src="/static/syntaxhighlighter/src/my_start_1.js"></script>





</body>

</html>