NumPy HttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet("https://www-staging.usay.co/app/surveys.json?access_token=6eebeac3dd1dc9c97a06985b6480471211a777b39aa4d0e03747ce6acc4a3369");
httpGet.addHeader(BasicScheme.authenticate(
new UsernamePasswordCredentials("usay", "isc00l"),
"UTF-8", false));
try
{
HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity responseEntity = httpResponse.getEntity();
inputStream = responseEntity.getContent();
}
catch(Exception e)
{
e.printStackTrace();
}
try
{
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "iso-8859-1"), 8);
stringBuilder = new StringBuilder();
stringBuilder.append(reader.readLine() + "\n");
String line = "0";
while ((line = reader.readLine()) != null)
{
stringBuilder.append(line + "\n");
}
inputStream.close();
result = stringBuilder.toString();
}
catch (Exception e)
{
Log.e("log_tag", "Error converting result " + e.toString());
}
Log.e("result",result);
return result;
和append
之间有什么区别?
我的观察是concatenate
有点快,如果没有指定轴,concatenate
会使数组变平。
append
答案 0 :(得分:35)
np.append
使用np.concatenate
:
def append(arr, values, axis=None):
arr = asanyarray(arr)
if axis is None:
if arr.ndim != 1:
arr = arr.ravel()
values = ravel(values)
axis = arr.ndim-1
return concatenate((arr, values), axis=axis)