小编San*_*Jha的帖子

Linux中的Visual Basic .Net

是否可以在Linux中运行Visual Basic .Net

我在Visual Basic中编写了代码,并使用Windows中的Visual Studio编译它.

可以在Linux中编写(和编译)相同的代码吗?

如果是,那么我需要在Linux上安装哪个软件?

是Visual Basic免费软件的Linux替代品吗?

vb.net linux

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

如何使用python更快地读取文件中的几行?

截至目前,我使用以下python代码:

file = open(filePath, "r")
lines=file.readlines()
file.close()
Run Code Online (Sandbox Code Playgroud)

假设我的文件有几行(10,000或更多),那么如果我为多个文件执行此操作,我的程序会变慢.有没有办法加快Python的速度?阅读各种链接我理解readlines将文件行存储在内存中,这就是代码变慢的原因.

我也尝试了以下代码,我得到的时间增加了17%.

lines=[line for line in open(filePath,"r")]
Run Code Online (Sandbox Code Playgroud)

python2.4中是否还有其他模块(我可能已经错过了).谢谢,桑迪亚

python file readlines

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

用于Windows的python 2.4中的cpuinfo

如何在python 2.4中获取cpuinfo.我想确定一台机器中的处理器数量.(代码应该是OS独立的).我已经为Linux编写了代码,但不知道如何使它适用于Windows.

import subprocess, re
cmd = 'cat /proc/cpuinfo |grep processor |wc'
d = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
lines = d.stdout.readlines()
lines = re.split('\s+', lines[0])
number_of_procs = int(lines[1])
Run Code Online (Sandbox Code Playgroud)

假设我没有在windows机器上安装cygwin,我只有python2.4.如果有一些可以为此目的调用的模块,或者为此功能编写代码的任何帮助,请告诉我.

谢谢,桑迪亚

python windows cpu-cores

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

使用 powershell 搜索文件中的多行文本

我不是 PowerShell 专家。我试图在文件中搜索多行字符串,但没有得到所需的结果。

这是我的代码:

$search_string = @("This is the first line`nThis is the second line`nThis is the third line")
$file_path = "log.txt"
$ret_string = @(Get-Content -Path $file_path | Where-Object{$_.Contains($search_string)}).Count
Write-Host $ret_string
Run Code Online (Sandbox Code Playgroud)

$ret_string设置为0虽然"log.txt"包含与 完全相同的内容$search_string

powershell

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

标签 统计

python ×2

cpu-cores ×1

file ×1

linux ×1

powershell ×1

readlines ×1

vb.net ×1

windows ×1