首先,对于Python来说,我是一个完全新手.但是,我编写了一段代码来查看RSS提要,打开链接并从文章中提取文本.这是我到目前为止:
from BeautifulSoup import BeautifulSoup
import feedparser
import urllib
# Dictionaries
links = {}
titles = {}
# Variables
n = 0
rss_url = "feed://www.gfsc.gg/_layouts/GFSC/GFSCRSSFeed.aspx?Division=ALL&Article=All&Title=News&Type=doc&List=%7b66fa9b18-776a-4e91-9f80- 30195001386c%7d%23%7b679e913e-6301-4bc4-9fd9-a788b926f565%7d%23%7b0e65f37f-1129-4c78-8f59-3db5f96409fd%7d%23%7bdd7c290d-5f17-43b7-b6fd-50089368e090%7d%23%7b4790a972-c55f-46a5-8020-396780eb8506%7d%23%7b6b67c085-7c25-458d-8a98-373e0ac71c52%7d%23%7be3b71b9c-30ce-47c0-8bfb-f3224e98b756%7d%23%7b25853d98-37d7-4ba2-83f9-78685f2070df%7d%23%7b14c41f90-c462-44cf-a773-878521aa007c%7d%23%7b7ceaf3bf-d501-4f60-a3e4-2af84d0e1528%7d%23%7baf17e955-96b7-49e9-ad8a-7ee0ac097f37%7d%23%7b3faca1d0-be40-445c-a577-c742c2d367a8%7d%23%7b6296a8d6-7cab-4609-b7f7-b6b7c3a264d6%7d%23%7b43e2b52d-e4f1-4628-84ad-0042d644deaf%7d"
# Parse the RSS feed
feed = feedparser.parse(rss_url)
# view the entire feed, one entry at a time
for post in feed.entries:
# Create variables from posts
link = post.link
title = post.title
# Add the link to the dictionary
n += 1
links[n] = link
for k,v in links.items():
# Open RSS feed …
Run Code Online (Sandbox Code Playgroud) 我使用Sphinx和autodocs功能来确保我们的项目中有很好的文档.
但是,在为方法或函数编写docstring时,我发现在文本中引用它们的参数很有用.但似乎没有一种结构化的方式来做到这一点.
我们可以说例如
Use ``name`` to set the username
Run Code Online (Sandbox Code Playgroud)
但是没有结构,要求你记住你用过的样式,如果你改变了样式,你必须追捕并杀死所有不正确的样式.
:param:在信息字段列表之外不起作用,所以你不能写
Use :param:`name` to set the username
Run Code Online (Sandbox Code Playgroud)我已经看到一些项目使用:parm:但是没有记录,似乎没有用.所以他们必须有一些定制
所以我希望我错过了一些令人眼花缭乱的事情.