这里有一个菜鸟,如果我错过了道歉.
我正在学习正则表达式并参与本课程:https: //regexone.com/lesson/capturing_groups.
在python解释器中,我尝试使用括号仅捕获搜索字符串的.pdf部分之前的内容,但我的结果尽管使用了parens但仍然捕获了它.我究竟做错了什么?
import re
string_one = 'file_record_transcript.pdf'
string_two = 'file_07241999.pdf'
string_three = 'testfile_fake.pdf.tmp'
pattern = '^(file.+)\.pdf$'
a = re.search(pattern, string_one)
b = re.search(pattern, string_two)
c = re.search(pattern, string_three)
print(a.group() if a is not None else 'Not found')
print(b.group() if b is not None else 'Not found')
print(c.group() if c is not None else 'Not found')
Run Code Online (Sandbox Code Playgroud)
返回
file_record_transcript.pdf
file_07241999.pdf
Not found
Run Code Online (Sandbox Code Playgroud)
但是应该回来
file_record_transcript
file_07241999
Not found
Run Code Online (Sandbox Code Playgroud)
谢谢!
有没有办法根据六边形的频率增加 pyplot.hexbin 中六边形的相对大小?我只能看到关键字参数的 binsize,它会影响十六进制的数量,但不会影响它们的大小。
但是在这篇文章中(大约 2/3 在标题“多元六边形分箱”下),它讨论了绘制大小与计数成正比的六边形,以便更清楚地观察趋势(见下图)
我是否错过了允许这样做的关键字参数?
谢谢!