Python Challenge笔记
来源:互联网 发布:手机淘宝联盟几号提现 编辑:程序博客网 时间:2024/06/09 22:05
Level 3
import reimport osdirect=os.getcwd()with open(direct+r'\code.txt','r') as file: code=file.read().replace('\n','')list1=re.findall(r'[^A-Z][A-Z]{3}([a-z])[A-Z]{3}[^A-Z]',code)#[^A-Z]表示匹配非大写字母1次。([a-z])带圆括号(),表示findall结果只返回[a-z]匹配的字母,不含前后的其他匹配字符print(''.join(list1))
Level 4
import urllib.requestimport re#number=12345%初始值number=72758%中途调整一次while number: try: url=f'http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing={number}' response=urllib.request.urlopen(url)#请求网页 number=re.findall('nothing is (\d+)',str(response.read()))[0]#抓取网页内容并匹配提取数字 except Exception:#找不到数字时findall返回空列表[],[][0]抛出异常 print(url) break
阅读全文
0 0
- Python Challenge笔记
- python challenge
- Python Challenge
- Python Challenge
- python challenge
- Python Challenge
- Python challenge
- python challenge
- Python Challenge
- Lua Challenge -- From Python Challenge
- Python Challenge 谜题0
- Python Challenge 谜题1
- Python Challenge 谜题2
- Python Challenge 谜题3
- Python Challenge 谜题4
- python challenge 4-6
- python challenge 7-9
- python challenge 10-12
- HDU 1003:Max Sum(简单dp)
- 2017.09.02【NOIP提高组】模拟赛B组
- C 文件读写(以判断闰年为例)
- 一些笔试题小汇总
- ionic应用程序跳转其它网站地址实现(themeablebrowser)相当于WebView
- Python Challenge笔记
- struts2是单例的吗
- MMORPG服务器架构
- mysql DDL DML
- 并发新特性—阻塞队列和阻塞栈
- C头文件编写基本规则
- hdu-5532 Almost Sorted Array(最长单调不xx序列)
- 夜间模式
- typedef的学习 数组指针与指针数组的差异