MAC OS X:我正在使用bundle install为我的应用程序安装gem但是得到错误以下我在我的gem文件中使用ruby'1.9.3',gem'trail','3.2.12'..
Installing gmail_xoauth 0.4.1
Installing omniauth 1.3.1
Installing httparty 0.13.7
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/userx/.rvm/rubies/ruby-1.9.3-p551/bin/ruby -r
./siteconf20170420-57041-h8rx0n.rb extconf.rb
creating Makefile
Compiling v8 for x64
Using python 2.7.12
Using compiler: /usr/bin/c++ (clang version 8.1.0)
../src/bignum.cc:761:7: error: variable 'i' is incremented both in the loop
header and in the loop body [-Werror,-Wfor-loop-analysis]
++i;
^
../src/bignum.cc:756:72: note: incremented here
for (int i = other.used_digits_ + exponent_diff; i < used_digits_; ++i) {
^
1 error generated.
make[1]: …Run Code Online (Sandbox Code Playgroud) 我正在逐行读取 JSON 文件。少数行包含 JSON 对象,而其他行包含 JSON 数组。我正在使用json.loads(line)函数从每一行获取 JSON。
def read_json_file(file_name):
json_file = []
with open(file_name) as f:
for line in f:
json_file.append((line))
json_array = []
for obj in json_file:
try:
json_array.append(json.loads(obj))
except ValueError:
print("data was not valid JSON")
return json_array
Run Code Online (Sandbox Code Playgroud)
有什么方法可以找出我正在读取的对象是 JSON 对象还是 JSON 数组?我想将所有结果保存在 json_array 中。
如果有人能帮助我,我将非常感谢你。