例如,我有这样的循环,在名称包含百分号的文件夹上调用dir,因此解释器尝试将这些字符之间的字符解析为变量.这样的文件夹例如在虚拟化解决方案(例如ThinApp)中是常见的,即将存储在本地用户AppData中的数据改为写入例如:X:\ My Virtualized App \%AppData%.
当然我知道可以通过将%加倍来实现它,但是不可能说服解释器在for循环中不解析这样的变量,例如:
FOR /F "tokens=*" %%F IN ('dir /b /s X:\myapp\%AppData% ') DO @(
echo %%F
)
Run Code Online (Sandbox Code Playgroud)
在这里,无论我尝试什么,加倍,四倍的百分比,或添加插入没有任何区别.传递给dir命令的路径已解析appdata,因此具有两个驱动器规范无效.
我的意思是不将其压缩为*.xpi.当我将带有扩展文件的文件夹从系统资源管理器拖到therirs插件管理器选项卡时,其他浏览器(如chrome或opera)可以理解,但当我解压缩*.xpi并尝试将其安装为文件夹时,firefox会显示:"此插件不能是安装,因为它显示损坏的"消息.
原因是当我尝试更改代码时,我必须每次将源文件打包到xpi然后刷新扩展名.换句话说,就像在chrome中一样,浏览器会在文件更改时自动更新扩展名.
我唯一能做的就是这个链接:
https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q568&format=jsonfm
Run Code Online (Sandbox Code Playgroud)
但这会产生大量无用的数据.我需要的是获取给定项的所有语句,但我看不到上面查询中的任何语句.
这将是:
{ "instance of" : "chemical element",
"element symbol" : "Li",
"atomic number" : 3,
"oxidation state" : 1,
"subclass of" : ["chemical element", "alkali metal"]
// etc...
}
Run Code Online (Sandbox Code Playgroud)
是否有这样的API或我必须刮网页?
我知道从std :: string获取正则表达式匹配的两种方法,但我不知道如何获得所有匹配它们各自的偏移量.
#include <string>
#include <iostream>
#include <regex>
int main() {
using namespace std;
string s = "123 apples 456 oranges 789 bananas oranges bananas";
regex r = regex("[a-z]+");
const sregex_token_iterator end;
// here I know how to get all occurences
// but don't know how to get starting offset of each one
for (sregex_token_iterator i(s.cbegin(), s.cend(), r); i != end; ++i) {
cout << *i << endl;
}
cout << "====" << endl;
// and here I know …Run Code Online (Sandbox Code Playgroud) input = cbind(c(3,7,3,5,2,9,1,4,6,4,7,3,7,4))
library(zoo)
output = cbind(rollmean(input,4))
print(input)
print(output)
Run Code Online (Sandbox Code Playgroud)
输出:
[,1]
[1,] 3
[2,] 7
[3,] 3
[4,] 5
[5,] 2
[6,] 9
[7,] 1
[8,] 4
[9,] 6
[10,] 4
[11,] 7
[12,] 3
[13,] 7
[14,] 4
[,1]
[1,] 4.50
[2,] 4.25
[3,] 4.75
[4,] 4.25
[5,] 4.00
[6,] 5.00
[7,] 3.75
[8,] 5.25
[9,] 5.00
[10,] 5.25
[11,] 5.25
Run Code Online (Sandbox Code Playgroud)
但是当我试图解决它时:
Error in cbind(input, output) :
number of rows of matrices must match (see arg 2)
Calls: print …Run Code Online (Sandbox Code Playgroud) 我正在编写的程序是一个简单的控制台应用程序,它获取参数,计算,然后返回数据.
我问这个是因为我正在尝试实现一个智能"press enter to exit"消息,只有在通过在资源管理器中单击其图标来调用控制台程序时才会运行该消息.没有它,结果是程序只闪烁一秒钟,但如果程序是从已经打开的控制台的上下文运行,那么同样的事情就变成了烦恼.当程序在bat或cmd文件中运行时会出现类似的事情,然后在最后暂停也不受欢迎,因为bat文件具有应该执行的'pause'命令.
所以,我们有两种模式:
"press enter to exit"什么时候开始:
示例代码:
element.addEventListener('click',function () {
this.style.backgroundColor = '#cc0000'
//after element was clicked once what to do here to remove this event ?
},false)
Run Code Online (Sandbox Code Playgroud)
在哪里做,是否可以直接在我发表评论的功能?
timeoutHandle = setTimeout(function() {
//code
},1000);
Run Code Online (Sandbox Code Playgroud)
alert(timeoutHandle)返回一些奇怪的数字,例如 1 或 2,它应该是类似的900并且倒计时到0函数被调用的时间吗?所以我想我做错了。
它应该没有问题:
#include <iostream>
#define _WIN32_WINNT 0x501
#include <windows.h>
using namespace std;
int main() {
HWND consoleWindow = GetConsoleWindow();
LPRECT lpRect;
GetWindowRect(consoleWindow,lpRect);
cout << lpRect.top <<endl;
}
Run Code Online (Sandbox Code Playgroud)
但相反,我得到了这个:
error: request for member 'top' in 'lpRect', which is of non-class type 'LPRECT {aka tagRECT*}'
Run Code Online (Sandbox Code Playgroud) 例如,我需要计算一个单词出现在列表中的次数,不按频率排序,而是按单词出现的顺序排序,即插入顺序.
from collections import Counter
words = ['oranges', 'apples', 'apples', 'bananas', 'kiwis', 'kiwis', 'apples']
c = Counter(words)
print(c)
Run Code Online (Sandbox Code Playgroud)
所以代替: {'apples': 3, 'kiwis': 2, 'bananas': 1, 'oranges': 1}
我宁愿得到: {'oranges': 1, 'apples': 3, 'bananas': 1, 'kiwis': 2}
我真的不需要这种Counter方法,任何可以产生正确结果的方法对我来说都是可以的.
c++ ×3
javascript ×2
batch-file ×1
c++11 ×1
console ×1
counter ×1
dictionary ×1
for-loop ×1
gcc ×1
python ×1
python-3.x ×1
r ×1
regex ×1
timeout ×1
variables ×1
wikidata ×1
wikidata-api ×1
winapi ×1
windows ×1
zoo ×1