小编Jun*_* HU的帖子

多处理和子进程有什么区别?

我的工作应该使用并行技术,我是python的新用户.所以我想知道你是否可以分享一些关于python multiprocessingsubprocess模块的资料.这两者有什么区别?

python subprocess multiprocessing

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

如何通过编写python脚本将所有py文件编译到文件夹中的pyc文件?

我在win系统上工作,我想知道一种方法,我可以使用一个可以在cmd行中运行的python脚本来批量编译py文件.我写了一个简单的python代码.

import py_compile, os, glob
dir = 'D:\\FAS\\config'
for f in glob.glob(dir + '\\*.py'):
    py_compile.compile(f)
    print "Success compile the file:   %s" % f
Run Code Online (Sandbox Code Playgroud)

它工作不方便,无法编译文件夹的子文件夹中的文件.我希望你的帮助.

python

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

使用GZipStream解压缩.gz文件

我有几个.gz文件,我想逐个解压缩它们.我在C#中使用GzipStream编写了一个简单的代码,但是失败了.我想知道一个正确而有用的方法来实现我想要的东西.非常感谢.

private string Extrgz(string infile)
{
    string dir = Path.GetDirectoryName(infile);
    string decompressionFileName = dir + Path.GetFileNameWithoutExtension(infile) + "_decompression.bin";
    using (GZipStream instream = new GZipStream(File.OpenRead(infile), CompressionMode.Compress))// ArgumentException...
    {
        using (FileStream outputStream = new FileStream(decompressionFileName, FileMode.Append, FileAccess.Write))
        {
            int bufferSize = 8192, bytesRead = 0;
            byte[] buffer = new byte[bufferSize];
            while ((bytesRead = instream.Read(buffer, 0, bufferSize)) > 0)
            {
                outputStream.Write(buffer, 0, bytesRead);
            }
        }
    }
    return decompressionFileName;
}
Run Code Online (Sandbox Code Playgroud)

c# filestream gzipstream

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

如何在C#中实现多个返回值,如python样式

我有一个python脚本:

def f():
    a = None
    b = None
    return (a, b)


a, b = f()
Run Code Online (Sandbox Code Playgroud)

在python中实现多个返回值非常容易.现在我想在C#中实现相同的结果.我试过几种方法,比如return int []或KeyValuePair.但两种方式看起来并不优雅.我想知道一个令人兴奋的解 非常感谢.

c# python function

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

object [] = object [] f = new object []和var f = new []之间的区别?

我是C#的新手,我想在最近的项目中使用匿名类型,但我面临一个需要你帮助的混乱问题.我首先使用对象[]但是我收到错误.代码如下所示:

        List<object> f = new List<object>(); 
        f.Add(new { Name = 1, Age = 31 });
        f.Add(new { Name = 2, Age = 31 });
        f.Add(new { Name = 3, Age = 4 });
        f.Add(new { Name = 4, Age = 1 });
        f.Add(new { Name = 5, Age = 1 });
        var a = f[0].Age; // no use
Run Code Online (Sandbox Code Playgroud)

但是这段代码很有用:

    var f = new []
    {
        new { Name = 1, Age = 31 },
        new { Name = 2, Age …
Run Code Online (Sandbox Code Playgroud)

c# anonymous-types

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

在Ubuntu中安装scikit-learn时有​​些麻烦

我只是从https://pypi.python.org/pypi/scikit-learn/下载scikit-learn安装包.
在安装软件包之前,我使用apt-get安装了几个依赖软件包:

sudo apt-get install build-essential python-dev python-numpy python-setuptools python-scipy libatlas-dev
Run Code Online (Sandbox Code Playgroud)

在我转到安装目录后,我运行命令python setup.py install.但收到回复error: could not create '/usr/local/lib/python2.7/dist-packages/sklearn': Permission denied

我发现问题是关于ATLAS和BLAS,但我不熟悉它们.所以我需要一些帮助来解决它.我将详细信息粘贴在终端中:

Appending sklearn.__check_build configuration to sklearn
Ignoring attempt to set 'name' (from 'sklearn' to 'sklearn.__check_build')
Warning: Assuming default configuration (svm/tests/{setup_tests,setup}.py was not found)Appending sklearn.svm.tests configuration to sklearn.svm
Ignoring attempt to set 'name' (from 'sklearn.svm' to 'sklearn.svm.tests')
/usr/lib/python2.7/dist-packages/numpy/distutils/system_info.py:1423: UserWarning: 
    Atlas (http://math-atlas.sourceforge.net/) libraries not found.
    Directories to search for the libraries can be specified in the
    numpy/distutils/site.cfg …
Run Code Online (Sandbox Code Playgroud)

python ubuntu blas atlas scikit-learn

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