我运行了以下命令(因为我的mac上有python2和python3):
$ CFLAGS = -I / usr / local / opt / icu4c / include LDFLAGS = -L / usr / local / opt / icu4c / lib sudo python3 -m pip install pyicu
错误信息如下:
安装收集的软件包:pyicu 运行setup.py安装pyicu ...错误 命令/ anaconda3 / bin / python3 -u -c完成输出“import setuptools,tokenize; file ='/ private / tmp / pip-build-l71tm0m4 / pyicu / setup.py'; f = getattr(tokenize,'open',open)( file ); code = f.read()。replace('\ r \ n','\ n'); f.close(); exec(编译(代码,文件,'exec'))“install --record /tmp/pip-7298jccr-record/install-record.txt --single-version-external-managed - 编译:
Building PyICU 2.0.3 for ICU 58.2
Adding CXXFLAGS="-I/anaconda3/include" from /anaconda3/bin/icu-config
Adding LDFLAGS="-Wl,-rpath,/anaconda3/lib -L/anaconda3/lib -licui18n -licuuc -licudata" from /anaconda3/bin/icu-config
running install
running build
running build_py
creating build
creating build/lib.macosx-10.7-x86_64-3.6
copying PyICU.py -> build/lib.macosx-10.7-x86_64-3.6
creating build/lib.macosx-10.7-x86_64-3.6/icu
copying icu/__init__.py -> build/lib.macosx-10.7-x86_64-3.6/icu
running build_ext
building '_icu' extension
creating build/temp.macosx-10.7-x86_64-3.6
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/anaconda3/include -arch x86_64 -I/anaconda3/include -arch x86_64 -I/anaconda3/include/python3.6m -c _icu.cpp -o build/temp.macosx-10.7-x86_64-3.6/_icu.o -DPYICU_VER="2.0.3" -I/anaconda3/include
In file included from _icu.cpp:27:
./common.h:38:13: error: unknown type name 'decltype'
typedef decltype(nullptr) nullptr_t;
^
./common.h:38:30: error: expected ';' after top level declarator
typedef decltype(nullptr) nullptr_t;
^
;
2 errors generated.
error: command 'gcc' failed with exit status 1
----------------------------------------
命令“/ anaconda3 / bin / python3 -u -c”import setuptools,tokenize; file ='/ private / tmp / pip-build-l71tm0m4 / pyicu / setup.py'; f = getattr(tokenize,'open',open)( file ); code = f.read()。replace('\ r \ n','\ n'); f.close() ; exec(编译(代码,文件,'exec'))“install --record /tmp/pip-7298jccr-record/install-record.txt --single-version-external-managed - -compile“失败,错误代码1在/ private / tmp / pip-build-l71tm0m4 / pyicu /
答案 0 :(得分:0)
根据@ n.m。,import requests
import json
import csv
response = requests.get(url).text //json source
data = json.loads(response)
newsdata = (data["response"]["docs"])
// These two lines reformat the date to what I want it to look like
newsdate = [y["pub_date"] for y in newsdata]
newsdate = [y.split('T')[0] for y in newsdate]
newsdata["pub_date"] = newsdate // This line is what I've tried to replace the json
newssnip = [y["snippet"] for y in newsdata]
newshead = [y["headline"]["main"] for y in newsdata]
for z in newsdata:
csvwriter.writerow([z["pub_date"], //This is the JSON data i want to reformat
z["headline"]["main"],
z["snippet"],
z["web_url"]])
需要添加到CFLAGS。