Python
共 7 篇文章
测试douban-python库的oauth
douban-python:http://code.google.com/p/douban-python/ examples测试成功,发现部分问题,如下: 1、使用老版本的web.py0.2,这个版本已经很难下到了~ 将examples改为0.3版本 2、验证总失败,发现demo.py中的collection函数中,使用两个变量接收client.get_access_token(request_key, request_secret)的三个返回值
2010-12-06 14:53 · Python
GAE-oAuth-python
转自 gae group I know the question of GAE + OAuth has come up before. In case it is useful to anyone, here is the code I used to get access to GMail inbox with OAuth. I use the base OAuth client classes from http://oauth.googlecode.com/svn/code/python/ , but unlike the example code (which uses httpli…
2010-12-02 11:02 · Python
The exit of python
今天ssh到一个公司机器上,进入python,发现竟然是2.4 太老了,准备换个版本,输入exit()竟无法退出 网上查了下,才发现: Python2.5之前的程序: >>> import sys >>> sys.exit() 2.5后(包括2.5)现在: >>> exit() 当然用Ctrl-D也可以了,貌似这个太暴力了(呵呵) 自iamsk7.appspot.com转移,2010-03-20,准备放弃自己做的blog ;)
2010-10-17 13:51 · Python
RSA算法的简单实现
我们的网络安全试验,需用任一语言实现rsa算法,我就用python实现了。 用python来实现,相对于c来说,代码较短,但是速度明显没有c的快。 RSA算法描述见: wiki 代码如下: #!/usr/bin/env python #-*-coding: utf-8-*- # author: "SK (skxiaonan@gmail.com)" # date: "Date: 2009/05/22 09:10:10" import math def isPrime(number): i=2 sqrtNumber=int(math.sqrt(number)) for i in range(2,…
2009-05-22 09:27 · Python
python中import & help()命令的使用
今天在测试python命令时,需要查看命令的解释,忽然发现python的内置help命令挺好用的,介绍给大家 首先,当你你需要查看某个命令的解释时,需要先导入它 例:import os help(os) help(os.path) 均可 但是help(path)不可以因为path未被导入局部名字空间 如果需要导入的话可以使用from os import path 就可以使用help(path)来查看path命令的解释 使用 from module import xxx 的一个坏处是,可能导致局部名字空间内名字的冲突 详细的分析请看:http://www.woodpecker.org.cn/d…
2009-04-26 12:24 · Python
python中os.path.isabs(path)的分析
这个本身是小组朋友问的问题,感觉不错,我给出的回答 问: >>> os.path.isabs("/home") True >>> os.path.isabs("/home/..") True >>> os.path.isabs("home/..") False 这里第二个应该是相对路径吧? 应该返回False? 答: 首先,给段资料 The current os.path.isabs documentation says: > isabs(path) > Return True if path is an absolute pathname (begins with a slash). Th…
2009-04-26 12:09 · Python
初学Python十进制转二进制遇到问题及分析
#!/usr/bin/python # -*- coding:utf-8 -*- #支持中文(上面一句) #很奇怪,在设定字符编码那句上面如果写上中文,也会出错 #导入模块 import string import sys def main(): print 'Input a decimal number: ' number = raw_input() #string.atoi('string', base) => int number = string.atoi(number) toTwo(number) #自定义函数 def toTwo(number): twoList=[] p=0 w…
2009-04-15 23:52 · Python