English 中文(简体)
在一个字典中加入联系
原标题:Joining links together in a dictionary

我有字塔链接,有一张图形图。 我如何能够与<代码>urljoin()功能一起加入第二个URL? 我试图做到的是完全连接起来,这样我可以行使一项休养职能:<条码>研究(),该功能将“URL”作为争辩,发现每个URL中的所有环节,并储存一个数据库中标明的链接数目。

迄今为止,我已经:

>>> links
{( href ,  http://reed.cs.depaul.edu/lperkovic/csc242/test2.html ): 1, ( href ,  test3.html ): 1}

页: 1

问题回答

(1) 在考虑字典中的钥匙时,没有“第一”或“第二”的概念;钥匙没有确定顺序。

2) 很不明确,你实际上试图做些什么。 如果你更努力地描述你重新努力解决的问题,你会得到更好的帮助。 另一方面,如果这是家务劳动,那么你就不在此寻求这种帮助。 相反,你们应该要求你们的TA。

我认为,你应重新考虑如何储存URL和URL碎片。 现在把他们拖到像你那样的dict子里,使事情变得比现在要困难得多。

一项建议是,在你把LLA储存起来之前,产生全部的URLs,将Rhref部分从les(和les)中删除,简单地将URLs本身用作钥匙。 与此类似:

from urlparse import urljoin
links = {}
urlbase =  http://reed.cs.depaul.edu/lperkovic/csc242/test2.html 
links[urljoin(urlbase,  test3.html )] = 1

这样做将产生这样的dict:

>>> links
{ http://reed.cs.depaul.edu/lperkovic/csc242/test3.html : 1}




相关问题
what is wrong with this mysql code

$db_user="root"; $db_host="localhost"; $db_password="root"; $db_name = "fayer"; $conn = mysqli_connect($db_host,$db_user,$db_password,$db_name) or die ("couldn t connect to server"); // perform query ...

Users asking for denormalized database

I am in the early stages of developing a database-driven system and the largest part of the system revolves around an inheritance type of relationship. There is a parent entity with about 10 columns ...

Easiest way to deal with sample data in Java web apps?

I m writing a Java web app in my free time to learn more about development. I m using the Stripes framework and eventually intend to use hibernate and MySQL For the moment, whilst creating the pages ...

join across databases with nhibernate

I am trying to join two tables that reside in two different databases. Every time, I try to join I get the following error: An association from the table xxx refers to an unmapped class. If the ...

How can I know if such value exists in database? (ADO.NET)

For example, I have a table, and there is a column named Tags . I want to know if value programming exists in this column. How can I do this in ADO.NET? I did this: OleDbCommand cmd = new ...

Convert date to string upon saving a doctrine record

I m trying to migrate one of my PHP projects to Doctrine. I ve never used it before so there are a few things I don t understand. In my current code, I have a class similar to this: class ...

热门标签