python rss解析与生成
PyRSS2Gen :rss生成
下载地址:http://www.dalkescientific.com/Python/PyRSS2Gen-1.0.0.tar.gz
例子:
Java代码
import datetime
import PyRSS2Gen
rss = PyRSS2Gen.RSS2(
title = "Andrew's PyRSS2Gen feed",
link = "http://www.dalkescientific.com/Python/PyRSS2Gen.html",
description = "The latest news about PyRSS2Gen, a "
"Python library for generating RSS2 feeds",
lastBuildDate = datetime.datetime.now(),
items = [
PyRSS2Gen.RSSItem(
title = "PyRSS2Gen-0.0 released",
link = "http://www.dalkescientific.com/news/030906-PyRSS2Gen.html",
description = "Dalke Scientific today announced PyRSS2Gen-0.0, "
"a library for generating RSS feeds for Python. ",
guid = PyRSS2Gen.Guid("http://www.dalkescientific.com/news/"
"030906-PyRSS2Gen.html"),
&n
相关文档:
>>> a = {'1':'2'}
>>> b = {'3':'4'}
>>> a+b
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'dict' and 'dict'
>>> a.update(b)
>>> a
{'1': '2', '3': '4'} ......
之前学习第九章的排序小结的时候,对sort()排序方法不理解,因为括号里面带了自定义的比较函数。
后来查手册,才发现sort()里面本来就带了这样的参数。能够自定义比较方法,确实很灵活。
不仅如此,在网上查到一个博客,作者不单停留在这表面,还查究了sort()的排序算法,确实有意思。
全文抄录如下:
http://blog.done ......
4、Tuples 元组
元组和Lists相似,但它是immutable,初始化后不能改变其内容,这在程序中有时候很有用,可以用来防止定义的变量内容被意外改变。
5、Files 文件
文件操作和c语言比较接近,下面只通过代码演示:
>>> f = open('data.txt','w')
>>> ......
1 你好
#打开新窗口,输入:
#! /usr/bin/python
# -*- coding: utf8 -*-
s1=input("Input your name:")
print("你好,%s" % s1)
'''
知识点:
* input("某字符串")函数:显示"某字符串",并等待用户输入.
......
import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough t ......