现在位置: 首页 > 编程语言 > 文章
2018年08月29日 编程语言 ⁄ 共 892字 评论关闭
备了个忘 1.创建应用程序代码 2.利用样板来包装代码     1.包含 Python 的头文件。          #include "Python.h" //需将python安装目录下的include文件夹包含进工程     2.为每个模块的每一个函数增加一个型如 PyObject* Module_func()的包装函数。     包装函数格式: static PyObject *Extest_fac(PyObject *self, PyObject *args) { int res; //parse result int num; //arg for fac() PyObject *retval; res = PyArg...
阅读全文
2018年08月29日 编程语言 ⁄ 共 781字 评论关闭
备了个忘 1.目前sae 的python空间还在内测中 到这里:http://appstack.sinaapp.com/apply获取使用python的权限 2.创建应用与默认版本,在本地文件夹中svn检出代码 3.修改检出的config.yaml文件,修改如下 name: your_app_name version: your_version libraries: - name: django   version: "1.4" handlers: - url: /static   static_dir: static 4.修改index.wsgi import os import django.core.handlers.wsgi import ...
阅读全文
2018年08月29日 编程语言 ⁄ 共 634字 评论关闭
''' Created on 2012-11-4 @author: Pandara ''' #input import sys m = input("backpack size:") n = input("objects sum:") objects_s = []#sequence s objects_v = []#sequence v input_str = raw_input("input objects' s:(a b c...)") input_str = input_str.split(" ") objects_s = [int(str) for str in input_str] input_str = raw_input("input objects' v:(a b c...)") input_str = input_str.split(" ") objec...
阅读全文
2018年08月29日 编程语言 ⁄ 共 5609字 评论关闭
来源:http://code.activestate.com/recipes/572196-rsa/ ## {{{ http://code.activestate.com/recipes/572196/ (r2) #!/usr/bin/python # -*- coding: utf-8 -*- """\ The author takes no responsibility for anything having anything to do with this code. Use at your own risk, or don't use at all. This is a Python implementation functions used in the RSA algorithm, as well as a file-like object for writin...
阅读全文
2018年08月29日 编程语言 ⁄ 共 2231字 评论关闭
''' Created on 2012-11-5 @author: Pandara ''' import math import random import sys def is_prime(num): ''' determine wether num is prime ''' for i in range(int(math.floor(float(num) / 2)) + 1)[2:]: if num % i == 0: return False return True def random_prime(low = 0, high = 100): ''' to get prime randomly low: lower bound of range h...
阅读全文
2018年08月29日 编程语言 ⁄ 共 1618字 评论关闭
转自:http://www.oschina.net/code/snippet_16840_1815 python是支持多线程的,并且是native的线程。主要是通过thread和threading这两个模块来实现的。thread是比较底层的模 块,threading是对thread做了一些包装的,可以更加方便的被使用。这里需要提一下的是python对线程的支持还不够完善,不能利用多 CPU,但是下个版本的python中已经考虑改进这点,让我们拭目以待吧。     threading模块里面主要是对一些线程的操作对象化...
阅读全文
2018年08月27日 编程语言 ⁄ 共 3232字 评论关闭
public final class PreferenceUtils { public static final int DEFFAULT_PAGE = 2; public static final String START_PAGE = "start_page"; private static PreferenceUtils sInstance; private final SharedPreferences mPreferences; public PreferenceUtils(final Context context) { mPreferences = PreferenceManager.getDefaultSharedPreferences(context); } ...
阅读全文