小编co2*_*f2e的帖子

在Python中删除字符串中的所有空格

我想从字符串,两端和单词之间消除所有空格.

我有这个Python代码:

def my_handle(self):
    sentence = ' hello  apple  '
    sentence.strip()
Run Code Online (Sandbox Code Playgroud)

但这只会消除字符串两边的空白.如何删除所有空格?

python trim removing-whitespace

715
推荐指数
10
解决办法
154万
查看次数

nginx ./configure error ubuntu 12.04

下载并尝试在执行命令时尝试配置nginx ./configure um得到此错误

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
Run Code Online (Sandbox Code Playgroud)

我执行了

apt-get build-dep nginx 
Run Code Online (Sandbox Code Playgroud)

命令你得到以下错误

The following packages have unmet dependencies:
libgd2-noxpm-dev : Depends: libgd2-noxpm (= 2.0.36~rc1~dfsg-6ubuntu2) but it is not    going to be installed
E: Build-dependencies for nginx could not be satisfied.
Run Code Online (Sandbox Code Playgroud)

我对libgd2-noxpm一无所知.这是我第一次使用nginx.如何克服这个错误.先感谢您

nginx

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

如何使用烧瓶中的ajax调用上传文件

嗨,我对烧瓶很新,我想使用ajax调用上传文件到服务器.如文档中所述,我将文件上传到html,如下所示:

<form action="" method=post enctype="multipart/form-data" id="testid">
 <table>
  <tr>
   <td>
     <label>Upload</label>
   </td>
   <td>
     <input id="upload_content_id" type="file" name="upload_file" multiple>
     <input type="button" name="btn_uplpad" id="btn_upload_id" class="btn-upload" value="Upload"/>

   </td>
  </tr>
 </table>
</form>
Run Code Online (Sandbox Code Playgroud)

我写了这个ajax处理程序

$(document).ready(function() {
    $("#btn_upload_id" ).click(function() {           
        $.ajax({
            type : "POST",
            url : "/uploadajax",
            cache: false,
            async: false,
            success : function (data) {},
            error: function (XMLHttpRequest, textStatus, errorThrown) {}
        });
    });
});
Run Code Online (Sandbox Code Playgroud)

我不知道如何从这里获取上传的文件(不是名字)

  <input id="upload_content_id" type="file" name="upload_file" multiple>
Run Code Online (Sandbox Code Playgroud)

并将文件保存在文件夹中.我不太确定如何从我编写的处理程序中读取文件:

@app.route('/uploadajax', methods = ['POST'])
def upldfile():
    if request.method == 'POST':
        file_val = request.files['file']
Run Code Online (Sandbox Code Playgroud)

如果有人能提供帮助,我将不胜感激.先感谢您

python ajax flask

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

如何在sqlite django ORM中实现having子句

我编写了django sqlite orm语法来检索特定的记录集:

from django.db.models.aggregates import Count

JobStatus.objects.filter(
    status='PRF'
).values_list(
    'job', flat=True
).order_by(
    'job'
).aggregate(
    Count(status)__gt=3
).distinct()
Run Code Online (Sandbox Code Playgroud)

但是它给了我一个错误,这个语法的sql等效对我来说很好.

这是我的sql等价物.

SELECT *
  FROM tracker_jobstatus
 WHERE status = 'PRF'
 GROUP BY job_id
HAVING COUNT(status) > 3;
Run Code Online (Sandbox Code Playgroud)

我得到的结果如下

+----+--------+--------+---------+---------------------+---------+
| id | job_id | status | comment | date_and_time       | user_id |
+----+--------+--------+---------+---------------------+---------+
| 13 |      3 | PRF    |         | 2012-11-12 13:16:00 |       1 |
| 31 |      4 | PRF    |         | 2012-11-12 13:48:00 |       1 |
+----+--------+--------+---------+---------------------+---------+
Run Code Online (Sandbox Code Playgroud)

我无法找到与此相关的django sqlite.

如果有人能提供帮助,我将非常感激.

python sqlite django orm django-models

21
推荐指数
2
解决办法
7429
查看次数

Android如何在res/values中添加自定义xml文件以及如何在系统中注册customvalues.xml

我想添加一个自定义xml,其中包含res/values文件夹的URL.我可以添加文件但是如何通过getResources()读取其内容?

android

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

Android如何传递Activity.class作为函数的参数

我最近从python转移到Android,我被困在这里.

这是我的类声明,用于为Alert Dialog创建一个接受必要参数的通用函数

public static AlertDialog.Builder getAlertDialog(String strArray[],
        String strTitle, Activity v) {

    return new AlertDialog.Builder(v)
    .setTitle(strTitle).setItems(strArray,
            new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            // TODO Auto-generated method stub
        }
    });
}
Run Code Online (Sandbox Code Playgroud)

但我无法通过这段代码调用此函数,这会给我一个错误

  getAlertDialog(strArray, strTitle, MakeCall.class).show();
Run Code Online (Sandbox Code Playgroud)

错误是

the method getAlertDialog(String[], String, Activity) in the type   MakeCallAlertDialog is not applicable for the arguments (String[], String, Class<TestActivity>)
Run Code Online (Sandbox Code Playgroud)

谁能告诉我如何正确地得到这个?先感谢您.

java android

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

如何通过rails中的命令行运行rake任务

我在一个名为的文件中定义了一个rake任务 file_locker_task.rake

namespace :myspace do
   task :process => :environment do
      FileLocker.lock_files   
   end
end
Run Code Online (Sandbox Code Playgroud)

如何从命令行执行此rake任务?我试过了:

rake myspace:processrake process但两者都抛出这样的错误:

rake aborted!
Don't know how to build task 'process'
Run Code Online (Sandbox Code Playgroud)

ruby rake ruby-on-rails

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

WCF错误:相对端点地址

对于WCF来说,这是一个新手.我想我搞砸了一下.所以这就是我到目前为止所做的,我在IIS中托管了我的WCF服务

首先是合同

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using YangkeeServer.dto;

namespace YangkeeServer
   {

public class Service1 : IService1
{
    [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, UriTemplate = "single")]
    public YangkeeTrailerDTO getTrailor()
    {
        return new YangkeeTrailerDTO()
        {
            loanFrom = "heaven"
        };
    }


    [WebInvoke(Method = "GET",
       ResponseFormat = WebMessageFormat.Json,
       UriTemplate = "datum/{id}")]
    public Test getName(string id)
    {
        return new Test()
        {
            Id = Convert.ToInt32(id) * 12,
            Name = "Leo Messi"
        };
    }
}
} …
Run Code Online (Sandbox Code Playgroud)

iis wcf iis-7 wcf-rest

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

嵌套使用语句的最佳实践?

我有一个代码块如下,我使用3个嵌套using块.

我发现使用try finally块我可以避免这种情况但是如果有两个以上的使用语句,那么最好的方法是什么?

private FileStream fileStream = null;
private Document document = null;
private PdfWriter pdfWriter =  null;

using (fileStream = new FileStream("ABC.pdf", FileMode.Create))
{
    using (document = new Document(PageSize.A4, marginLeft, marginRight, marginTop, marginBottom))
    {
        using (pdfWriter = PdfWriter.GetInstance(document, fileStream))
        {
            document.AddAuthor(metaInformation["author"]);
            document.AddCreator(metaInformation["creator"]);
            document.AddKeywords("Report Generation using I Text");
            document.AddSubject("Document subject");
            document.AddTitle("The document title");
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

.net c# using-statement

12
推荐指数
2
解决办法
2938
查看次数

为什么公共语言运行时不能支持Java

今天,公共语言运行时支持许多语言,包括Iron Python和Iron Ruby.我们同样可以在Java Run Time环境中使用J Ruby和J Python.如果是这样,为什么.net框架工作的公共语言运行时间不能支持Java?你只是好奇地知道,虽然你可能会认为这是一个愚蠢的问题.

.net c# java ironpython

10
推荐指数
2
解决办法
4375
查看次数