url

《算法图解》第五章笔记与课后练习_散列函数与散列表

假装没事ソ 提交于 2020-01-22 00:12:01
软件环境:Python 3.7.0b4 一、散列函数 无论你给它什么数据,它都还你一个数字。它必须满足一些要求: 它必须是一致的。例如,假设你输入apple时得到的是4,那么每次输入apple时,得到的都必须为4。 它应将不同的输入映射到不同的数字。例如,如果一个散列函数不管输入是什么都返回1,那它就不是好的散列函数。最理想的情况是 将不同的输入映射到不同的数字。 使用函数dict来创建散列表 >>> book = dict() >>> book["apple"] = 0.67 # 一个苹果的价格是67美分 >>> book["milk"] = 1.49 >>> book["avocado"] = 1.60 >>> print(book) {'apple': 0.67, 'milk': 1.49, 'avocado': 1.6} >>> print(book["milk"]) 1.49 # 牛奶的价格 散列表由键和值组成。在前面的散列表book中,键为商品名,值为商品价格。散列表将键映射到值。 二、应用案例 1,将散列表用于查找 假设你要创建一个电话簿,将姓名映射到电话号码。该电话簿需要提供如下功能: 添加联系人及其电话号码。 通过输入联系人来获悉其电话号码。 下面我们来使用散列表进行对电话簿的创建映射和查找。 2,防止重复 假如你负责管理一个投票站,每个人只能投一票

SVN常用命令

こ雲淡風輕ζ 提交于 2020-01-21 13:56:45
SVN (Subversion) 是一个自由、开源的项目源代码版本控制工具。 目前,绝大多数开源软件和企业代码管理,都使用SVN作为代码版本管理软件。 Subversion将文件存放在中心版本 库里 ,这个版本库很像一个普通的文件服务器。不同的是,它可以记录每一次文件和目录的修改情况,这样就可以在需要的回滚时,将 数据恢复 到以前的版本,并可以查看数据的更改细节。 SVN 官方网址: Apache Subversion SVN 服务器配置: 安装SVN服务器 一、 SVN常用命令 1、将文件checkout到本地目录 svn checkout path(path是服务器上的目录) 简写:svn co 2、往版本库中添加新的文件 svn add file 3、将改动的文件提交到版本库 svn commit -m “LogMessage” [-N] [--no-unlock] PATH(如果选择了保持锁,就使用–no-unlock开关) 简写:svn ci 4、加锁/解锁 svn lock -m “LockMessage” [--force] PATH svn unlock PATH 5、更新到某个版本 svn update -r m path 简写:svn up 6、查看文件或者目录状态 1)svn status path(目录下的文件和子目录的状态,正常状态不显示) 2)svn

JavaWeb请求中文乱码

眉间皱痕 提交于 2020-01-21 12:02:15
解决中文乱麻问题,页面端发出的数据作两次encodeURI   var name="张三";   encodeURI(encodeURI(name)); 后台解码:   URLDecoder.decode(name,"UTF-8"); URL编码与两次encodeURI   当使用地址栏提交查询参数时,如果不编码,非英文字符会按照操作系统的字符集进行编码提交到服务器,服务器会按照配置的字符集进行解码,所以如果两者不一致就会导致乱码。   encodeURI函数采用UTF-8对URL进行编码,所以如果服务器在进行解码时使用的是其他的编码方式就会出现乱码,默认的服务器配置的解码字符集都不是UTF-8,所以大部分情况下地址栏提交中文查询参数时会产生乱码;针对这种情况,可以连续使用两次encodeURI在客户端(主要指浏览器)对非英文字符进行编码,然后在服务端使用java.net.URLDecoder(String."UTF-8")解码,即可得到正确的中文。   如果只进行一次encodeURI,得到的是UTF-8形式的URL,服务器端通过request.getParameter()解码查询参数(通常是iso-8859-1)就会得到乱码。   如果进行两次encodeURI,第一次编码得到的是UTF-8形式的URL,第二次编码得到的依然是UTF-8形式的URL

各种基金调用介绍

醉酒当歌 提交于 2020-01-21 11:14:32
各种基金调用介绍( haoservice 介绍) using System; using System.Net; using System.Text; namespace all { class Program { static void Main(string[] args) { string key = "**************************"; string url = "http://apis.haoservice.com/lifeservice/netdata/all?key="+key; WebClient wc = new WebClient(); wc.Encoding=Encoding.UTF8; string str=wc.DownloadString(url); Console.WriteLine(str); Console.ReadKey(); } } } 各种不同基金调用只用把url换掉,申请key值即可 1.股票型基金 接口信息 URL: http://apis.haoservice.com/lifeservice/netdata/innov 支持格式:json http请求方式:GET 参数说明: 名称 类型 必须 说明 key string 是 应用APPKEY(应用详细页查询) 返回结果: { "reason":"Success",

Change service reference URL in code

独自空忆成欢 提交于 2020-01-21 10:48:25
问题 I'm working in a Windows Phone 8 project and in order to use some webservices I added a service reference with a specific URL . My problem is the URL because it changes fom time to time so I need to let the user insert the new URL from some menu when the app is running. I know how to change it in Visual Studio but now I need to change it in code when the app is running..so my question is: how do I change the URL in code? I have done some search and the file "app.config" seems to do the job

Base Uri without a trailing slash

不问归期 提交于 2020-01-21 10:47:31
问题 If I create a Uri using the UriBuilder like this: var rootUrl = new UriBuilder("http", "example.com", 50000).Uri; then the AbsoluteUri of rootUrl always contain a trailing slash like this: http://example.com:50000/ What I would like, is to create a Uri object without the trailing slash, but it seems impossible. My workaround is to store it as a string instead, and do something ugly like this: var rootUrl = new UriBuilder("http", "example.com", 50000).Uri.ToString().TrimEnd('/'); I have heard

Base Uri without a trailing slash

做~自己de王妃 提交于 2020-01-21 10:46:09
问题 If I create a Uri using the UriBuilder like this: var rootUrl = new UriBuilder("http", "example.com", 50000).Uri; then the AbsoluteUri of rootUrl always contain a trailing slash like this: http://example.com:50000/ What I would like, is to create a Uri object without the trailing slash, but it seems impossible. My workaround is to store it as a string instead, and do something ugly like this: var rootUrl = new UriBuilder("http", "example.com", 50000).Uri.ToString().TrimEnd('/'); I have heard

android: Is it possible to dowload file to disk given an xml (from a URL)?

旧街凉风 提交于 2020-01-21 10:16:09
问题 I have a URL, for example http://somedomain.com/sync_login/go123/go and it gives an XML, if you're gonna view it in web browser (i use firefox), the output is something like this: <SyncLoginResponse> <Videos> <Video> <name>27/flv</name> <title>scooter</title> <url>http://somedomain.com/tabletcms/tablets/tablet_content/000002/videos/</url> <thumbnail>http://somedomain.com/tabletcms/tablets/tablet_content/000002/thumbnails/106/jpg</thumbnail> </Video> </Videos> <Slideshows> <Slideshow> <name>44

python爬取百度搜索结果url汇总

泄露秘密 提交于 2020-01-21 09:39:48
写了两篇之后,我觉得关于爬虫,重点还是分析过程 分析些什么呢: 1)首先明确自己要爬取的目标   比如这次我们需要爬取的是使用百度搜索之后所有出来的url结果 2)分析手动进行的获取目标的过程,以便以程序实现   比如百度,我们先进行输入关键词搜索,然后百度反馈给我们搜索结果页,我们再一个个进行点击查询 3)思考程序如何实现,并克服实现中的具体困难 那么我们就先按上面的步骤来,我们首先认识到所搜引擎,提供一个搜索框,让用户进行输入,然后点击执行 我们可以先模拟进行搜索,发现点击搜索之后的完整url中有一项很关键,如下 http://www.baidu.com/s?wd=搜索内容...... 后面的内容我们尝试去除之后再次请求上面的url,发现返回的信息一样,我们就可以断定请求的url只需要填入wd这个参数即可 接着我们就应该进行尝试requests.get()查看是否能正常返回页面,防止百度的反爬虫 嘿,幸运的是返回页面正常哈哈~ (当然如果没有返回到正常信息,只要设置好headers或者严格的cookies就行了) import requests url = 'http://www.baidu.com/s?wd=......' r = requests.get(url) print r.status_code,r.content 好,接下来我们就想知道怎么爬取所有的结果

用爬虫爬取笔趣阁小说

五迷三道 提交于 2020-01-21 09:36:05
#时间 2019年3月4日19:16:06#:https://www.bequge.com #功能:爬取笔趣阁任何小说。 from urllib import request from bs4 import BeautifulSoup #此函数用来获取每章对应的小说,并保存小说 def secondOpenURL(url,ch_name): # 请求每章详细内容 date = request.urlopen(url).read().decode('gbk') soup = BeautifulSoup(date, 'html.parser').find('div', attrs={'id': 'content'}) # 对正文进行处理,去除多余的字 novel = str(soup).replace('<br/>', '').replace('<div id="content">', '').replace('</div>', '') #换成相对应的保存地址。最好是绝对路径 filepath = '../Day02/novel_剑来/剑来/%s'%(ch_name) with open(filepath, 'w', encoding='utf-8') as f: f.write(novel) f.close() print('%s-》缓存完成'%(ch_name)) #