現在位置: 首頁 > 編程語言 > 文章
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); } ...
閱讀全文