小编abb*_*bot的帖子

如何在linux上使用python检查NTFS分区上的隐藏文件和文件夹?

NTFSlinux机器上使用分区.我想找出隐藏的文件和文件夹在我的NTFS分区上linux使用python.

我怎样才能实现这一目标python.任何代码片段/链接将不胜感激.

谢谢.

python linux filesystems ntfs

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

优化部分字典密钥匹配

我有一个字典,它使用4元组作为它的关键.我需要找到字典中与部分其他元组部分匹配的所有键.我有一些代码可以做到这一点,但它很慢,需要优化.

这就是我追求的:

Keys:
(1, 2, 3, 4)
(1, 3, 5, 2)
(2, 4, 8, 7)
(1, 4, 3, 4)
Match:
(1, None, 3, None)
Result:
[(1, 2, 3, 4), (1, 4, 3, 4)]
Run Code Online (Sandbox Code Playgroud)

当前代码:

def GetTuples(self, keyWords):
    tuples = []
    for k in self.chain.iterkeys():
        match = True
        for i in range(self.order):
            if keyWords[i] is not None and keyWords[i] != k[i]:
                match = False
                break
        if match is True:
            tuples.append(k)
    return tuples
Run Code Online (Sandbox Code Playgroud)
  • keyWords是一个包含我想要匹配的值的列表
  • self.chain是字典
  • self.order是元组的大小
  • len(keyWords)总是= len(k)
  • '无'被认为是外卡
  • 字典非常庞大(这种方法需要大约800毫秒才能运行,大约300mb),所以空间也是一个考虑因素

我基本上都在寻找对这种方法的优化,或者更好的存储方法.

python algorithm optimization

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

Mx align-regexp与Cu Mx align-regexp行为不一致

我试图为emacs编写一些新的对齐规则,并发现这种奇怪且不一致的行为.当前缓冲内容:

"some thing" like => this
   hello => world
and => again
Run Code Online (Sandbox Code Playgroud)

输入M-xalign-regexpRET[[:lower:]]+\(\s-+\)=>RET结果后看起来像所需:

"some thing" like => this
             hello => world
             and => again
Run Code Online (Sandbox Code Playgroud)

但在C-uM-xalign-regexpRET[[:lower:]]+\(\s-+\)=>RET1RET1RETyRET我得到这个之后:

"some thing" like => this
   hello          => world
and               => again
Run Code Online (Sandbox Code Playgroud)

如果我把它放进去,就会发生同样的(错误的)事情align-rules-list.如何解决这个问题?我想先得到结果.

emacs elisp alignment

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

在Fortran 95中将任意浮点字符串转换为实数

有没有简单的方法将任意浮点字符串转换为fortran中的实数?想想类似的东西strtodREAD语句的问题是所有浮点格式编辑描述符都需要显式宽度.到目前为止,我所做的最好的解决方法是:

pure function strtod(s)
  real(kind=8) :: strtod
  character(len=*), intent(in) :: s
  character(len=32) :: fmt
  integer :: dot
  dot = index(s, ".")
  if(dot < 1) then
     write(fmt, '("(F",I0,".0)")'), len_trim(s)
  else
     write(fmt, '("(F",I0,".",I0,")")'), len_trim(s), len_trim(s)-dot
  end if
  read(s,fmt), strtod
end function strtod
Run Code Online (Sandbox Code Playgroud)

但我想知道我是否遗漏了某些东西,可能有更好的方法吗?

fortran fortran90 fortran95

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

如果我的函数在处理时失败,System.MessageQueue(MSMQ)消息是否会丢失?

我使用以下代码发送消息:

var transaction = new MessageQueueTransaction())
transaction.Begin(  );

var message = new Message
{
   Body = myContent,
   Recoverable = true
};

m_oMessageQueue.Send( message , myTransaction );

transaction.Commit( );
Run Code Online (Sandbox Code Playgroud)

并使用a BeginRecieveReceiveCompleted事件处理程序接收它.

如果我的事件处理程序在调用之前失败EndRecieve,那么该消息是否应保留在队列中并且可用于后续的接收调用?我看到的行为是消息永远消失了.(或者可能会有超时,之后它会再次出现?)

更新接收消息的代码如下所示.

var messageQueue = new MessageQueue( myPath );
messageQueue.ReceiveCompleted += messageQueue_ReceiveCompleted_ThrowException;
messageQueue.BeginReceive();
Run Code Online (Sandbox Code Playgroud)

出于测试目的,我在messageQueue_ReceiveCompleted_ThrowException事件处理程序中抛出异常.

然后我用一个工作事件处理程序重复上面的代码,但我没有被调用.

c# msmq message-queue

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

使用M2Crypto加载DER编码的RSA密钥

该方法M2Crypto.RSA.RSA().save_key_der()可用于以DER格式保存密钥.但是,我没有M2Crypto.RSA.load_key_der()像我期望的那样看到相应的方法.

有没有办法使用M2Crypto加载DER编码的RSA密钥?

python m2crypto

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

是否可以在fortran中使用类型构造函数中的指针?

在一些Fortran 95代码中,我有一个带指针字段的类型.我想声明一个模块变量type(foo)在编译时初始化.像这样的东西:

module foo_module
  implicit none
  type foo_type
     integer :: x
     logical, pointer :: x_flag => null()
  end type foo_type

  logical, target :: bar_flag
  ! this does not compile of course:
  type(foo_type) :: bar = foo_type(1, bar_flag)
end module foo_module
Run Code Online (Sandbox Code Playgroud)

上面的代码片段无法编译.我知道我可以bar在运行时使用单独的子例程进行初始化,例如:

module foo_module
  implicit none
  type foo_type
     integer :: x
     logical, pointer :: x_flag => null()
  end type foo_type

  logical, target :: bar_flag
  type(foo_type) :: bar
contains
  subroutine init()
    bar%x = 1
    bar%x_flag => bar_flag
  end …
Run Code Online (Sandbox Code Playgroud)

constructor fortran pointers fortran90 fortran95

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

如何提高HttpWebResponse的性能?

我正在尝试构建一个发送和接收来自网站的响应的应用程序.

我在Stack Overflow上阅读的解决方案都没有解决我的问题,所以我认为我的代码可以使用优化.

我有以下主题:

void DomainThreadNamecheapStart()
{
    while (stop == false)
    {
        foreach (string FromDomainList in DomainList.Lines)
        {
            if (FromDomainList.Length > 1)
            {
                // I removed my api parameters from the string
                string namecheapapi = "https://api.namecheap.com/foo" + FromDomainList + "bar";

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(namecheapapi);
                request.Proxy = null;
                request.ServicePoint.Expect100Continue = false;

                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                StreamReader sr = new StreamReader(response.GetResponseStream());

                status.Text = FromDomainList + "\n" + sr.ReadToEnd();

                sr.Close();
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

单击按钮时会调用此线程:

private void button2_Click(object sender, EventArgs e)
{
    stop …
Run Code Online (Sandbox Code Playgroud)

c# performance https httpwebrequest

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