我jq用来改造我的JSON.
JSON字符串:
{"channel": "youtube", "profile_type": "video", "member_key": "hello"}
通缉输出:
{"channel" : "profile_type.youtube"}
我的命令:
__PRE__
我知道下面的命令连接字符串.但它的工作原理与上述不同:
__PRE__
如何使用ONLY jq实现我的结果?
我正在构建一个python 3.6AWS Lambda部署包,并面临着一个问题SQLite.
在我的代码中,我使用的是nltk其中一个import sqlite3文件.
到目前为止的步骤:
部署包只有我在根目录中使用的python模块.我收到错误:
Unable to import module 'my_program': No module named '_sqlite3'
将_sqlite3.so添加/home/my_username/anaconda2/envs/py3k/lib/python3.6/lib-dynload/_sqlite3.so到包根目录中.然后我的错误改为:
Unable to import module 'my_program': dynamic module does not define module export function (PyInit__sqlite3)
将SQLite预编译的二进制文件添加sqlite.org到我的包的根目录,但我仍然得到错误点#2.
我的设置:Ubuntu 16.04,python3 virtual env
AWS lambda env: python3
我该如何解决这个问题?
我想在我的网站上针对关键字在谷歌搜索中显示第一张图片.我真的很喜欢这方面的一些指示.
谢谢!
我有以下类型的json:
{
"foo": "hello",
"bar": [
{
"key": "k1",
"val": "v1"
},
{
"key": "k2",
"val": "v2"
},
{
"key": "k3",
"val": "v3"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我想输出以下内容:
"hello", 1, "k1", "v1"
"hello", 2, "k2", "v2"
"hello", 3, "k3", "v3"
Run Code Online (Sandbox Code Playgroud)
我正在使用jq转换这个,答案也应该是jq转换.
我目前在:
echo '{"foo": "hello","bar": [{"key": "k1","val": "v1"},{"key": "k2","val": "v2"},{"key": "k3","val": "v3"} ]}' | jq -c -r '.bar[] as $b | [.foo, ($b | .key, .val)] | @csv'
Run Code Online (Sandbox Code Playgroud)
这给了我:
"hello","k1","v1"
"hello","k2","v2"
"hello","k3","v3"
Run Code Online (Sandbox Code Playgroud)
我怎样才能获得索引来显示正在解析的数组元素?
我编写了以下代码来反转字符串而不使用<algorithm> reverse.我写:
#include <string.h>
#include <iostream>
using namespace std;
void reverse(char *str){
int sizeStr=strlen(str);
int firstChar,lastChar,temp;
for(lastChar = (sizeStr - 1),firstChar = 0 ; lastChar>firstChar ; lastChar--, firstChar++){
temp = str[firstChar];
str[firstChar]=str[lastChar];
str[lastChar] = temp;
}
}
int main() {
char *str;
str = "myname";
reverse(str);
cout << str << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我得到了段错误str[firstChar]=str[lastChar];.请帮我弄清楚我的错误.
注意:我声明char str[] = "myname"并完美地工作.但是根据你的所有解释,我们必须学会*str和str[].非常感谢.在帮助新程序员方面走了很长的路.
jq ×2
json ×2
aws-lambda ×1
c++ ×1
csv ×1
image ×1
javascript ×1
python-3.x ×1
sqlite ×1
string ×1