python - Notepad++ 的 Python 脚本中的可选参数

标签 python notepad++ scintilla optional-arguments

我正在尝试自动删除我在 Notepad++ 上编辑的 HTML 代码上的某些文本。我发现插件“Python Script”将是一个不错的选择。

在我看来,我应该使用 Editor.rereplace 工作如下:

Editor.rereplace(search, replace[, flags[, startPosition[, endPosition[, maxCount]]]]) 

唯一的问题是我想使用可选参数“maxCount”而不是“flags”、“startposition”和“endposition”

我尝试过这样编码:

Editor.rereplace("old", "new", maxCount=1)

我猜这是行不通的,因为它不是真正的 Python,而是 Scintilla 语言。因此,我查看了 Scintilla 文档,在我看来,Scintilla 中“自然”不存在可选参数。

最佳答案

语法定义为 [opt1 [opt2 [opt3]]] 而不是 [opt1] [opt2] [opt3] 这意味着您不能使用 opt3指定 opt1 和 2。为什么不只提供适合您的标志、开始和结束位置的值?

我会尝试:

Editor.rereplace("matchRegex", "replaceWith",0,0,1,1)

地点:

Flags: 0
Start: 0
End: 1
MaxCount: 1

关于python - Notepad++ 的 Python 脚本中的可选参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31076814/

相关文章:

python - 如何处理CreateView中的对象引用

xml - Notepad++ shortcut.xml 文件在编辑后被清除

notepad++ - 需要将多个文件合并到一个目录中

regex - Notepad++ 用括号替换括号

c# - ScintillaNET 自动完成列表问题

c# - WPF XAML 问题中的 ScintillaNET

python - PySpark DataFrames - 使用不同类型的列之间的比较进行过滤

python - 如何向量化这个矩阵运算?

python - 如何使用while循环从python中搜索txt文件

c++ - pygtkscintilla 自动缩进