小编Ale*_*lli的帖子

如何在Android Emulator中找到数据库文件的路径?

我正在Android模拟器中执行一些sqlite查询.我想知道数据库文件存储的路径.请给我一些如何找到它的想法.如果你可以提供一些代码片段.

urs,s.kumaran.

android

4
推荐指数
1
解决办法
2万
查看次数

扩展方法没有显示

我正在为MVC Web应用程序中的HtmlHelper类创建扩展方法.什么都没有显示,甚至没有显示默认的InputExtensions.

public static class HtmlHelpers
{
    public static void RegisterScriptInclude(this HtmlHelper htmlhelper, string script)
    {
        if (!RegisteredScriptIncludes.ContainsValue(script))
        {
            RegisteredScriptIncludes.Add(RegisteredScriptIncludes.Count, script);
        }
    }

    public static string RenderScripts(this HtmlHelper htmlhelper)
    {
        var scripts = new StringBuilder();
        foreach (string script in RegisteredScriptIncludes.Values)
        {
            scripts.AppendLine("<script src='" + script + "' type='text/javascript'></script>");
        }
        return scripts.ToString();

    }

    private static SortedList<int, string> RegisteredScriptIncludes
    {
        get
        {
            SortedList<int, string> value = (SortedList<int, string>)HttpContext.Current.Items["RegisteredScriptIncludes"];
            if (value == null)
            {
                value = new SortedList<int, string>();
                HttpContext.Current.Items["RegisteredScriptIncludes"] = value;
            } …
Run Code Online (Sandbox Code Playgroud)

extension-methods

3
推荐指数
1
解决办法
2304
查看次数

来自Design Pattern的Bruce Eckel的代码片段:我对它是如何工作感到困惑

我一直在阅读布鲁斯·埃克尔在Python中思考.目前,我正在阅读模式概念章节.在本章中,Eckel展示了python中Singletons的不同实现.但是我对Alex Martelli的Singleton代码(利用继承,而不是私有的嵌套类)有一个不清楚的理解.

这是我对目前代码的理解:

  • 所有Singleton对象都是Borg的子类
  • _shared_state最初是一个空字典
  • _shared_state是一个全局变量; 使用Borg的任何对象都具有相同的_shared_state

到目前为止我的困惑:

  • 这是什么行的目的:self.__dict__ = self._shared_state; 或者字典的目的
  • Singletons的所有对象最终是如何具有相同的val,即使它们都是该类的不同实例.
  • 总的来说,我不知道博格是如何运作的

许多人提前感谢!

- 三

*更新:每个Singleton对象创建后_shared_state中存储的内容是什么?

#: Alex' Martelli's Singleton in Python
class Borg:
  _shared_state = {}
  def __init__(self):
    self.__dict__ = self._shared_state

class Singleton(Borg):
  def __init__(self, arg):
    Borg.__init__(self)
    self.val = arg
  def __str__(self): return self.val

x = Singleton('sausage')
print …
Run Code Online (Sandbox Code Playgroud)

python

3
推荐指数
2
解决办法
1933
查看次数

如何从方案中的列表中删除元素

如何从列表中删除元素ex: - list = [1 2 3 4]

我想出了一些代码.我想我错了.

 (define delete item
   (lambda (list)
   (cond
    ((equal?item (car list)) cdr list)
     (cons(car list)(delete item (cdr list))))))
Run Code Online (Sandbox Code Playgroud)

scheme

3
推荐指数
2
解决办法
3万
查看次数

尝试在 python 中 pickle 一个列表

尝试使用pickle在python中保存整数列表,遵循许多来源给我的确切方法,但我仍然遇到相同的错误。这是简化版本:

import pickle
a=[0,4,8,[3,5]]
with open(blah.pickle, 'wb') as b:
    pickle.dump(a,b)
Run Code Online (Sandbox Code Playgroud)

我总是收到错误:

NameError: name 'blah' is not defined
Run Code Online (Sandbox Code Playgroud)

出了什么问题?

python pickle

3
推荐指数
1
解决办法
6904
查看次数

Google Translation API

有没有人使用Google翻译API?使用它的最大长度限制是多少?

google-translate google-translation-api

2
推荐指数
1
解决办法
3473
查看次数

将struct转换为unsigned char*

如何将以下内容转换structunsigned char*

typedef struct {
    unsigned char uc1;
    unsigned char uc2;
    unsigned char uc3;
    unsigned char uc5;
    unsigned char uc6;
} uchar_t;

uchar_t *uc_ptr = new uchar;
unsigned char * uc_ptr2 = static_cast<unsigned char*>(*uc_ptr);
// invalid static cast at the previous line
Run Code Online (Sandbox Code Playgroud)

c++ type-conversion static-cast

2
推荐指数
1
解决办法
9468
查看次数

什么是逻辑编程?和其他有什么不同

今天我和其他朋友谈过,他说他有逻辑编程技巧,所以我很好奇.

logic programming-languages prolog

2
推荐指数
1
解决办法
1180
查看次数

如何获得python 2.4.3的uuid模块

我在使用的服务器上有一个旧版本的python,无法升级它.有没有办法获得uuid模块?

python

1
推荐指数
1
解决办法
3446
查看次数

Google App Engine的Python API问题

我遇到了我的API问题,我无法创建用户记录/将其存储在Google数据存储区中.我收到下面列出的JSON响应.

我发现奇怪的另一件事是当它在右上角使用Google API Explorer时,它有一个红色感叹号,上面写着"方法需要授权".它希望我为用户电子邮件授权OAUTH Scope.

更新:这是我通过GAE获得的错误日志.

    Encountered unexpected error from ProtoRPC method implementation: ServerError (Method PhotoswapAPI.user_create expected response type <class 'photoswap_api_messages.UserCreateResponseMessage'>, sent <type 'NoneType'>)
Traceback (most recent call last):
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/protorpc-1.0/protorpc/wsgi/service.py", line 181, in protorpc_service_app
    response = method(instance, request)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/endpoints-1.0/endpoints/api_config.py", line 1332, in invoke_remote
    return remote_method(service_instance, request)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/protorpc-1.0/protorpc/remote.py", line 419, in invoke_remote_method
    type(response)))
ServerError: Method PhotoswapAPI.user_create expected response type <class 'photoswap_api_messages.UserCreateResponseMessage'>, sent <type 'NoneType'>
Run Code Online (Sandbox Code Playgroud)

有谁知道如何解决这个问题,它返回503?我错过了什么吗?

    503 Service Unavailable

- Hide headers -

cache-control:  private, max-age=0
content-encoding:  gzip
content-length: …
Run Code Online (Sandbox Code Playgroud)

python google-app-engine google-cloud-endpoints

1
推荐指数
1
解决办法
1000
查看次数