Python 中没有 switch/case 语法,如果使用 if/elif/else 会出现代码过长、不清晰等问题。 而借助字典就可以实现 switch 的功能 def case1(): # 第一种情况执行的函数 pri...
Python
列表换行join函数
int = '\n' float = ' ' str = [] a = input('任务名称:\n') b = input('等级限制 最低等级:\n') c = input('最高等级:\n') d = input('任务简介:\n') str.append(a) str.append('%s~%s' % (b, c)) str.appe...
HAI.py
import requests a = 5 b = input('你要做什么?\n1.爬小说') if b == '1': while True: res = requests.get('http://www.xbiquge.la/13/13959/593902%s.html' % a) res.encoding = 'utf-8'...
Python中过滤HTML标签的函数
#用正则简单过滤html的<>标签 import re str = "<img /><a>srcd</a>hello</br><br/>" str = re.sub(r'</?\w+[^>]*>','',str) print (str) import re test='<p>just for test</p>...
MacOS 解决“import requests No module named requests”
MacOS 解决“import requests No module named requests” 系统信息 sw_vers ProductName: Mac OS X ProductVersion: 10.12.2 BuildVersion: 16C67 2.测试脚本 #内容如下: cat test.py #!/usr/...