问题列表 - 第22188页

Python:传递一个带参数的函数作为参数

def lite(a,b,c):
    #...

def big(func): # func = callable()
    #...


#main
big(lite(1,2,3))
Run Code Online (Sandbox Code Playgroud)

这该怎么做?
以什么方式将带参数的函数传递给另一个函数?

python function

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

如何在read.csv中声明一千个分隔符?

我想要读入的数据集包含带和不带逗号的数字作为千位分隔符:

"Sudan", "15,276,000", "14,098,000", "13,509,000"
"Chad", 209000, 196000, 190000
Run Code Online (Sandbox Code Playgroud)

我正在寻找一种方法来读取这些数据.

任何暗示赞赏!

csv r data-structures

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

如何在网络中广播消息?

我正在研究用C编写的客户端 - 服务器应用程序.我想向本地网络上的所有可用机器广播消息.

如何使用C中常用的套接字系统调用来做到这一点?

c sockets network-programming

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

jQuery和long int id

我遇到了下一个问题:

在我们的数据库中,我们有带有id的对象,如4040956363970588323.我正在jQuery上编写一些客户端向导,用于与这些对象进行交互.客户端通过Ajax请求接收有关对象的基础数据,如:

$.ajax({
        url: "/api/pages/",
        type: "get",
        dataType: "json",
        data: {"id": site_id},
        success: function(data){
            if (data.success){
                for (var pidx in data.pages){
                    console.log(data.pages[pidx].id);
                    var li = $('<li class="ui-widget-content"></li>');
                    var idf = $('<input type="hidden" id="pid" value="{0}"/>'.format(data.pages[pidx].id))
                    var urlf = $('<input type="hidden" id="purl" value="{0}"/>'.format(data.pages[pidx].url))
                    li.text(data.pages[pidx].title);
                    li.append(idf);
                    li.append(urlf);
                    $("#selectable_pages_assign").append(li);
                }
                pages_was = $("#selectable_pages_assign>li");
            }
            else
                 updateTips(data.message);
        },
        error: function(){
             updateTips("Internal erro!");
        }
})
Run Code Online (Sandbox Code Playgroud)

所以,正如你所看到的,我发送的数据就像JSON对象(一些服务器代码):

return HttpResponse(dumps({
                        "success": True,
                        "pages": [{"id": page.id, "title": page.title, "url": page.image} for page in …
Run Code Online (Sandbox Code Playgroud)

javascript floating-point jquery floating-accuracy

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

在Visual Studio .NET IDE中加载2个解决方案

是否可以一次在Visual Studio .NET IDE中加载多个解决方案,以便两个解决方案都出现在解决方案资源管理器中?

谢谢

visual-studio

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

C char to string(将char传递给strcat())

我的问题是将char转换为字符串我必须传递给strcat()一个字符串附加到字符串,我该怎么办?谢谢!

#include <stdio.h>
#include <string.h>

char *asd(char* in, char *out){
    while(*in){
        strcat(out, *in); // <-- err arg 2 makes pointer from integer without a cast
        *in++;
    }
    return out;
}

int main(){
    char st[] = "text";
    char ok[200];
    asd(st, ok);
    printf("%s", ok);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c string char strcat

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

PHP isset($ this)并在静态和对象上下文中使用相同的对象方法

我正在研究一个需要通过静态函数调用和对象方法访问的类.我发现的一件事是我在多个函数中复制逻辑.

简化示例:

class Configurable{

    protected $configurations = array();

    protected static $static_configurations = array();

    public function configure($name, $value){

        // ...lots of validation logic...

        $this->configurations[$name] = $value;

        }

     public static function static_configure($name, $value){

        // ...lots of validation logic (repeated)...

        self::$static_configurations[$name] = $value;

        }

    }
Run Code Online (Sandbox Code Playgroud)

我已经找到了解决方案,但感觉非常脏:

class Configurable{

    protected $configurations = array();

    protected static $static_configurations = array();

    public function configure($name, $value){

        // ...lots of validation logic...

        if (isset($this)){
            $this->configurations[$name] = $value;
            }
        else{
            self::$static_configurations[$name] = $value;
            }

        }

    }
Run Code Online (Sandbox Code Playgroud)

我也需要静态功能,以便我可以在整个应用程序中设置配置.此外,这种技术的好处是我可以在两个范围中使用相同的方法名称.

这样的测试范围有问题吗?性能问题,前向兼容性问题等.它在PHP 5.2上都适用于我,我不需要支持<5.

php oop static scope isset

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

使用mysql转义字符串时出错

我的代码有什么问题,我只是一个初学者.该错误称这是一个未定义的索引.一条记录被添加到mysql,但它只是0.这样做的正确方法是什么?

$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("Hospital", $con);


$hospnum = mysql_real_escape_string($_POST['HOSPNUM']);
$rnum =  mysql_real_escape_string($_POST['ROOMNUM']);
$adate = mysql_real_escape_string($_POST['ADATE']);

$adtime = mysql_real_escape_string($_POST['ADTIME']);
$lname = mysql_real_escape_string($_POST['LASTNAME']);
$fname = mysql_real_escape_string($_POST['FIRSTNAME']);
$mname = mysql_real_escape_string($_POST['MIDNAME']);

$cs = mysql_real_escape_string($_POST['CSTAT']);
$age = mysql_real_escape_string($_POST['AGE']);
$ad = mysql_real_escape_string($_POST['ADDRESS']);
$bday = mysql_real_escape_string($_POST['BDAY']);

$telnum = mysql_real_escape_string($_POST['TELNUM']);
$sex = mysql_real_escape_string($_POST['SEX']);
$stats1 = mysql_real_escape_string($_POST['STAT']);
$stats2 = mysql_real_escape_string($_POST['STAT2']);
$stats3 = mysql_real_escape_string($_POST['STAT3']);
$stats4 = mysql_real_escape_string($_POST['STAT4']);
$stats5 = mysql_real_escape_string($_POST['STAT5']);
$stats6 = mysql_real_escape_string($_POST['STAT6']);
$stats7 = mysql_real_escape_string($_POST['STAT7']);
$stats8 = mysql_real_escape_string($_POST['STAT8']);
$nurse …
Run Code Online (Sandbox Code Playgroud)

php mysql

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

来自C#的Outlook 2007 - COM异常,TYPE_E_LIBNOTREGISTERED

我正在尝试制作一个可以打开新的Outlook 2007消息的程序.

我引用了COM选项卡Microsoft Outlook 12.0 ObjectLibrary.

这些项目出现在VS的参考文献中:

Microsoft.Office.Core
Microsoft.Office.Inerop.Outlook
Run Code Online (Sandbox Code Playgroud)

现在我尝试调用以下代码:

var _outlookInstance = new Microsoft.Office.Interop.Outlook.Application();
var _message = (OutlookApp.MailItem)_outlookInstance.CreateItem(OutlookApp.OlItemType.olMailItem);
Run Code Online (Sandbox Code Playgroud)

其中OutlookApp == Microsoft.Office.Interop.Outlook命名空间.

在调用第二行列表时,我不断收到此异常:( InvalidCastException)

无法将"Microsoft.Office.Interop.Outlook.ApplicationClass"类型的COM对象强制转换为接口类型"Microsoft.Office.Interop.Outlook._Application".此操作失败,因为由于以下错误,对IID为"{00063001-0000-0000-C000-000000000046}"的接口的COM组件的QueryInterface调用失败:库未注册.(HRESULT的例外情况:0x8002801D(TYPE_E_LIBNOTREGISTERED)).

该代码在我的其他工作站上适用于Outlook 2003.

我会很感激任何想法如何解决它.

c# com interop office-interop outlook-2007

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

如何将List <int>传递给服务引用(C#,VS2008)

我遇到的问题是我创建了一个Web服务和一个Windows窗体(单独的解决方案).我使用服务引用将web服务添加到表单应用程序,我可以将"int"或"字符串"传递给Web服务没问题,但我无法传递int或List的数组<int>

Web服务代码如下:

using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Web.Services;

namespace CalculateService
{
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]

    public class Service1 : System.Web.Services.WebService
    {
        [WebMethod]
        public int CalcluateSum(List<int> listInt)
        {
            int sum = listInt.Sum();
            return sum;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

并且客户端代码是:

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CalculateForm
{
    public partial class FormCalculate : Form
    {
        List<int> intArray = new List<int>();

        public FormCalculate()
        { …
Run Code Online (Sandbox Code Playgroud)

c# web-services

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