小编Emm*_*mma的帖子

python中等效的matlab渐变函数

我在python中搜索matlab渐变函数的实现.下面说明了示例输出.

我在Matlab中使用它的方式是:

img = rgb2gray(imread('img.png'));
[dx,dy] = gradient(img);
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

谢谢

python statistics gradient

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

如何修复最佳重载方法匹配有一些无效的参数?

代码有什么问题,在标题中得到错误.我认为这是一个语法错误,但我不确定,因为我几乎没有关于错误实际含义的信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{

class Program
{

    static void Main(string[] args)
    {

        Console.WriteLine("Please Input Number of Rows you want to make in your pyrimid: ");

        int num = int.Parse(Console.Read()); // error here

        Console.WriteLine(num);// Just to check if it is getting the right number
        Console.Read();//This is Here just so the console window doesn't close when the program runs

    }
}
}
Run Code Online (Sandbox Code Playgroud)

编辑:只是为了澄清,我希望代码只是从用户获得一个数字,然后打印用户输入的数字.

编辑:为快速回应干杯:D

c#

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

如何在OSX上使用Python 2.7 Tkinter安装和使用TkDnD?

我花了一些时间来寻找可行的解决方案来在OSX平台上使用Python Tkinter进行Drap和Drop行为,找到的最可能的解决方案是TkDnD库. http://sourceforge.net/projects/tkdnd/files/

但是我找不到任何关于安装的手册或指南,基本上没有OSX上的样品......任何人都可以与我分享他们的经验吗?

此外,使用Tkinter作为GUI解决方案不是一个好的选择吗?我的用户都是OSX平台,所有这些机器上都预安装了Python.有什么好的建议,无需额外安装即可找到本机GUI支持?PyQT似乎是另一种选择,但不确定它是否需要在客户端计算机上进行额外安装.

谢谢.埃利斯

python macos tkinter python-2.7 python-3.x

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

如何从std :: regex_error获取解释性字符串?

我的节目正在投掷std::regex_error().我想知道错误是什么,因为正则表达式对我来说是合法的.我基本上做了这个:

try {
    // offending code
} catch (std::regex_error& e) {
    log_error("Regex error: " << e.what() << ", " << e.code());
}
Run Code Online (Sandbox Code Playgroud)

输出是:

Regex error: regex_error, 4
Run Code Online (Sandbox Code Playgroud)

这不是特别有用.4是什么意思?code()en.cppreference.com条目只说:

返回传递给std :: regex_error构造函数的std :: regex_constants :: error_type.

error_type的条目给出了错误代码列表,所有错误代码都是"未指定"的.

我没有办法,只能这样做吗?

switch (e.code()) {
    case std::regex_constants::error_collate: return "error_collate";
    case std::regex_constants::error_ctype: return "error_ctype";
    // etc ...
}
Run Code Online (Sandbox Code Playgroud)

c++ regex error-handling c++11

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

为 PostCSS 设置配置文件

我正在使用 PostCSS,我想添加 Post-uncss。我不使用任务运行器,只使用 Postcss-cli。我的 package.json 现在看起来像这样:

"css-clean": "npx postcss src\\css\\main.css -u autoprefixer --replace && npx postcss src\\css\\main.css -u css-declaration-sorter --replace --no-map"
Run Code Online (Sandbox Code Playgroud)

它变得相当长。我看到提到 PostCSS 可以有一个配置文件“postcss.config.js”。文章中唯一提到的就是骨架:

module.exports = {
    plugins: {
      'autoprefixer': {},
      'css-declaration-sorter': {}
    }
  };
Run Code Online (Sandbox Code Playgroud)

uncss 文档只说选项:

{
  html: ['index.html', 'about.html', 'team/*.html'],
  ignore: ['.fade']
}
Run Code Online (Sandbox Code Playgroud)

我希望如果有人有使用配置文件的经验来提供一些建议,因为我不相信这个功能是有据可查的。

html css postcss

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

如何使用innerHTML更新大小为X的数组?

当我尝试运行这个脚本时,它会更新我的数组一秒钟,但似乎在函数运行后,文档恢复正常.

解决这个问题的最佳方法是什么?

<p id="demo"></p>

<form>
    <input type="submit" onclick="add_value()"/>
</form>


<script>    
    var array = ["1", "2", "3"];
    document.getElementById("demo").innerHTML = array[3];

    function add_value() {
        array.push("69");
        document.getElementById("demo").innerHTML = array[3];
        document.getElementById("demo2").innerHTML = array[3];
    }
</script>
Run Code Online (Sandbox Code Playgroud)

html javascript

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

Pam.exec 退出代码 8

我正在尝试使用pam.d在用户登录时执行脚本。现在我正在编辑该/etc/pam.d/su文件。每次我登录用户时都会收到“退出代码 8”。

我使用的命令:

session optional pam_exec.so /etc/calendar/test
Run Code Online (Sandbox Code Playgroud)

该路径/etc/calendar/test是测试脚本的路径:

echo hi
Run Code Online (Sandbox Code Playgroud)

最终我将实现一个脚本来记录登录的用户和时间:

user=$(whoami)
date=$(date)
echo $user logged in at $date >> /etc/calendar/tripwire_file
Run Code Online (Sandbox Code Playgroud)

对此问题提供的任何见解将不胜感激。

linux bash scripting pam

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

ConEmu 中集成了带有 ZSH 的 WSL Bash - 在此处打开问题

我正在使用 Ubuntu Bash,并在 WSL、Windows 10 上安装了 ZSH。

命令(ConEmu 任务设置):

 "%WINDIR%\System32\wsl.exe ~" -cur_console:p
Run Code Online (Sandbox Code Playgroud)

命令(ConEmu 集成设置):

-Single -run {Bash::ubuntu} -cur_console:n 
Run Code Online (Sandbox Code Playgroud)

ConEmu 中集成的所有其他终端我都可以在当前项目文件夹中右键单击打开,但 Ubuntu Bash 始终在默认文件夹 (~) 中打开。

我尝试了此处描述的设置: ConEmu + WSL:在当前选项卡目录中打开新控制台

因此,使用命令:

set "PATH=%ConEmuBaseDirShort%\wsl;%PATH%" & %ConEmuBaseDirShort%\conemu-cyg-64.exe --wsl -C~ -cur_console:pm:/mnt
Run Code Online (Sandbox Code Playgroud)

它的工作原理与我的情况相同。

与正确的:

 set "PATH=%ConEmuBaseDirShort%\wsl;%PATH%" & %ConEmuBaseDirShort%\conemu-cyg-64.exe --wsl -cur_console:pm:/mnt
Run Code Online (Sandbox Code Playgroud)

终端在当前文件夹中打开并且可以工作,但在 Bash 中打开,不再有 ZSH。

我将不胜感激你的帮助。

bash ubuntu conemu windows-subsystem-for-linux

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

RegEx字词表现:\ w与[a-zA-Z0-9_]

我想知道通过的字符列表,\w仅仅是它[a-zA-Z0-9_]还是可以覆盖更多字符?

我问这个问题,是因为基于\d是不同的[0-9],是低效率的

\wvs [a-zA-Z0-9_]:大规模中哪一个更快?

php c# regex perl pcre

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

从背面开始将字符串分开

我有以下问题:

如果我有给定的字符串,'abcdefg'我想将其拆分为长度为3的子字符串数组,即[ 'abc', 'def']

为此,我使用String.prototype.match():

'abcdefg'.match(/.{1,3}/g);
Run Code Online (Sandbox Code Playgroud)

但是,如果我的输入字符串的长度不能被3整除,'abcdefgh'则结果为['abc', 'def', 'gh'],但是我需要结果为['ab', 'cde', 'fgh']

有没有一种优雅的方法呢?

javascript regex

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