using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks; namespace Common
{
/// <summary>
/// HttpClient的帮助类
/// 2015年11月12日14:43:45
/// </summary>
public class HttpClientHelper
{
/*Edit Desc: 提取默认的Http Heads UserAgen Author:Xuja Time:2016-5-3 16:46:29*/
private static readonly string userAgen = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36"; /// <summary>
/// 根据Url地址Get请求返回数据
/// 2015年11月12日14:50:02
/// </summary>
/// <param name="url">请求的地址</param>
/// <param name="ch_httpcode">http状态码</param>
/// <returns>字符串</returns>
public static string GetResponse(string url, out string httpStatusCode)
{
httpStatusCode = string.Empty;
HttpClient httpClient = new HttpClient(new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.GZip });
HttpResponseMessage response = null;
try
{
//httpClient.MaxResponseContentBufferSize = 256000;
httpClient.DefaultRequestHeaders.Add("user-agent", userAgen);
//httpClient = new HttpClient();
//using (HttpClient httpClient = new HttpClient())
//{
httpClient.CancelPendingRequests();
httpClient.DefaultRequestHeaders.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
Task<HttpResponseMessage> taskResponse = httpClient.GetAsync(url);
taskResponse.Wait();
response = taskResponse.Result;
//using (HttpResponseMessage response = taskResponse.Result)
//{ //HttpResponseMessage response = httpClient.GetAsync(url).Result;
if (response.IsSuccessStatusCode)
{
Task<System.IO.Stream> taskStream = response.Content.ReadAsStreamAsync();
taskStream.Wait();
//此处会抛出异常:不支持超时设置,对返回结果没有影响
System.IO.Stream dataStream = taskStream.Result;
System.IO.StreamReader reader = new System.IO.StreamReader(dataStream);
string result = reader.ReadToEnd(); return result;
}
//}
return null;
//}
}
catch
{
return null;
}
finally
{
if (response != null)
{
response.Dispose();
}
if (httpClient != null)
{
httpClient.Dispose();
}
}
} /// <summary>
/// 根据Url地址Get请求返回数据
/// xuja
/// 2015年11月12日14:50:02
/// </summary>
/// <param name="url">请求的地址</param>
/// <returns>字符串</returns>
public static string GetResponse(string url)
{
HttpClient httpClient = new HttpClient(new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.GZip });
HttpResponseMessage response = null;
try
{
//httpClient.MaxResponseContentBufferSize = 256000;
httpClient.DefaultRequestHeaders.Add("user-agent", userAgen);
//httpClient = new HttpClient();
//using (HttpClient httpClient = new HttpClient())
//{
httpClient.CancelPendingRequests();
httpClient.DefaultRequestHeaders.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
Task<HttpResponseMessage> taskResponse = httpClient.GetAsync(url);
taskResponse.Wait();
response = taskResponse.Result;
//using (HttpResponseMessage response = taskResponse.Result)
//{ //HttpResponseMessage response = httpClient.GetAsync(url).Result;
if (response.IsSuccessStatusCode)
{
Task<System.IO.Stream> taskStream = response.Content.ReadAsStreamAsync();
taskStream.Wait();
System.IO.Stream dataStream = taskStream.Result;
System.IO.StreamReader reader = new System.IO.StreamReader(dataStream);
string result = reader.ReadToEnd(); return result;
}
//}
return null;
//}
}
catch
{
return null;
}
finally
{
if (response != null)
{
response.Dispose();
}
if (httpClient != null)
{
httpClient.Dispose(); }
}
} /// <summary>
/// 根据Url地址Get请求返回实体
/// xuja
/// 2015年11月12日14:50:02
/// </summary>
/// <param name="url">请求的地址</param>
/// <returns>实体</returns>
public static T GetResponse<T>(string url)
{
HttpClient httpClient = new HttpClient(new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.GZip });
HttpResponseMessage response = null;
try
{
//using (HttpClient httpClient = new HttpClient())
//{
//httpClient.MaxResponseContentBufferSize = 256000;
httpClient.DefaultRequestHeaders.Add("user-agent", userAgen);
httpClient.CancelPendingRequests();
httpClient.DefaultRequestHeaders.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
//HttpResponseMessage response = httpClient.GetAsync(url).Result;
Task<HttpResponseMessage> taskResponse = httpClient.GetAsync(url);
taskResponse.Wait();
T result = default(T);
response = taskResponse.Result;
//using (HttpResponseMessage response = taskResponse.Result)
//{
if (response.IsSuccessStatusCode)
{
Task<System.IO.Stream> taskStream = response.Content.ReadAsStreamAsync();
taskStream.Wait();
System.IO.Stream dataStream = taskStream.Result;
System.IO.StreamReader reader = new System.IO.StreamReader(dataStream);
string s = reader.ReadToEnd(); result = JsonConvertTool.DeserializeObject<T>(s); }
//}
return result;
//}
}
catch (Exception e)
{
var resp = new HttpResponseMessage(HttpStatusCode.InternalServerError)
{
Content = new StringContent(e.ToString()),
ReasonPhrase = "error"
};
//throw new HttpResponseException(resp);
return default(T);
}
finally
{
if (response != null)
{
response.Dispose();
}
if (httpClient != null)
{
httpClient.Dispose(); } }
} /// <summary>
/// 处理Get的Url
/// des:huyf
/// </summary>
/// <param name="dic"></param>
/// <returns></returns>
public static string WithParameters(Dictionary<string, string> dic)
{
string result = "?";
foreach (var item in dic)
{
result += item.Key + "=" + item.Value + "&";
}
result = result.Remove(result.Length - 1); return result;
} /// <summary>
/// Post请求返回字符
/// </summary>
/// <param name="url">请求地址</param>
/// <param name="postData">请求数据</param>
/// <returns>字符</returns>
public static string PostResponse(string url, string postData)
{
HttpClient httpClient = new HttpClient(new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.GZip });
HttpResponseMessage response = null;
try
{
//using (HttpClient httpClient = new HttpClient())
//{
httpClient.MaxResponseContentBufferSize = 256000;
httpClient.DefaultRequestHeaders.Add("user-agent", userAgen);
httpClient.CancelPendingRequests();
httpClient.DefaultRequestHeaders.Clear();
HttpContent httpContent = new StringContent(postData);
httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
Task<HttpResponseMessage> taskResponse = httpClient.PostAsync(url, httpContent);
taskResponse.Wait();
response = taskResponse.Result;
//using (HttpResponseMessage response = taskResponse.Result)
//{
//HttpResponseMessage response = httpClient.PostAsync(url, httpContent).Result;
if (response.IsSuccessStatusCode)
{
Task<System.IO.Stream> taskStream = response.Content.ReadAsStreamAsync();
taskStream.Wait();
System.IO.Stream dataStream = taskStream.Result;
System.IO.StreamReader reader = new System.IO.StreamReader(dataStream);
string result = reader.ReadToEnd();
return result;
}
//}
return null;
//}
}
catch
{
return null;
}
finally
{
if (response != null)
{
response.Dispose();
}
if (httpClient != null)
{
httpClient.Dispose(); } } }
/// <summary>
/// Post请求返回字符
/// </summary>
/// <param name="url">请求地址</param>
/// <param name="postData">请求数据</param>
/// <returns>字符</returns>
public static string PostResponse(string url, object obj)
{
HttpClient httpClient = new HttpClient(new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.GZip });
HttpResponseMessage response = null;
try
{
//using (HttpClient httpClient = new HttpClient())
//{
httpClient.MaxResponseContentBufferSize = 256000;
httpClient.DefaultRequestHeaders.Add("user-agent", userAgen);
httpClient.CancelPendingRequests();
httpClient.DefaultRequestHeaders.Clear();
string postData = JsonConvertTool.SerializeObject(obj);
HttpContent httpContent = new StringContent(postData);
httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
Task<HttpResponseMessage> taskResponse = httpClient.PostAsync(url, httpContent);
taskResponse.Wait();
response = taskResponse.Result;
//using (HttpResponseMessage response = taskResponse.Result)
//{
//HttpResponseMessage response = httpClient.PostAsync(url, httpContent).Result;
if (response.IsSuccessStatusCode)
{
Task<System.IO.Stream> taskStream = response.Content.ReadAsStreamAsync();
taskStream.Wait();
System.IO.Stream dataStream = taskStream.Result;
System.IO.StreamReader reader = new System.IO.StreamReader(dataStream);
string result = reader.ReadToEnd();
return result;
}
else
{
//LogHelper.WriteInfo(typeof(HttpClientHelper), "结果:" + response.StatusCode + "内容:" + JsonConvertTool.SerializeObject(obj));
}
//}
return null;
//}
}
catch (Exception exception)
{
//LogHelper.Error("结果:异常 内容:" + JsonConvertTool.SerializeObject(obj) + "ex:" + exception.Message, exception);
return null;
}
finally
{
if (response != null)
{
response.Dispose();
}
if (httpClient != null)
{
httpClient.Dispose(); } } }
/// <summary>
/// Post请求返回实体
/// </summary>
/// <param name="url">请求地址</param>
/// <param name="postData">请求数据</param>
/// <returns>实体</returns>
public static T PostResponse<T>(string url, string postData)
{
HttpClient httpClient = new HttpClient(new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.GZip });
HttpResponseMessage response = null;
try
{
//using (HttpClient httpClient = new HttpClient())
//{
httpClient.MaxResponseContentBufferSize = 256000;
httpClient.DefaultRequestHeaders.Add("user-agent", userAgen);
httpClient.CancelPendingRequests();
httpClient.DefaultRequestHeaders.Clear();
HttpContent httpContent = new StringContent(postData); httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
T result = default(T);
Task<HttpResponseMessage> taskResponse = httpClient.PostAsync(url, httpContent);
taskResponse.Wait();
response = taskResponse.Result;
//using (HttpResponseMessage response = taskResponse.Result)
//{
//HttpResponseMessage response = httpClient.PostAsync(url, httpContent).Result;
if (response.IsSuccessStatusCode)
{
Task<System.IO.Stream> taskStream = response.Content.ReadAsStreamAsync();
taskStream.Wait();
System.IO.Stream dataStream = taskStream.Result;
System.IO.StreamReader reader = new System.IO.StreamReader(dataStream);
string s = reader.ReadToEnd();
result = JsonConvertTool.DeserializeObject<T>(s);
}
//}
return result;
//}
}
catch
{
return default(T);
}
finally
{
if (response != null)
{
response.Dispose();
}
if (httpClient != null)
{
httpClient.Dispose(); } } } /// <summary>
/// Post请求返回实体
/// </summary>
/// <param name="url">请求地址</param>
/// <param name="postData">请求数据</param>
/// <returns>实体</returns>
public static T PostResponse<T>(string url, object obj)
{
HttpClient httpClient = new HttpClient(new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.GZip });
HttpResponseMessage response = null;
try
{
//using (HttpClient httpClient = new HttpClient())
//{
httpClient.MaxResponseContentBufferSize = 256000;
httpClient.DefaultRequestHeaders.Add("user-agent", userAgen);
httpClient.CancelPendingRequests();
httpClient.DefaultRequestHeaders.Clear();
string postData = JsonConvertTool.SerializeObject(obj);
HttpContent httpContent = new StringContent(postData); httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
T result = default(T);
Task<HttpResponseMessage> taskResponse = httpClient.PostAsync(url, httpContent);
taskResponse.Wait();
response = taskResponse.Result;
//using (HttpResponseMessage response = taskResponse.Result)
//{
//HttpResponseMessage response = httpClient.PostAsync(url, httpContent).Result;
if (response.IsSuccessStatusCode)
{
Task<System.IO.Stream> taskStream = response.Content.ReadAsStreamAsync();
taskStream.Wait();
System.IO.Stream dataStream = taskStream.Result;
System.IO.StreamReader reader = new System.IO.StreamReader(dataStream);
string s = reader.ReadToEnd(); result = JsonConvertTool.DeserializeObject<T>(s);
}
//}
return result;
//}
}
catch
{
return default(T);
}
finally
{
if (response != null)
{
response.Dispose();
}
if (httpClient != null)
{
httpClient.Dispose(); }
}
} /// <summary>
/// Put请求返回字符
/// </summary>
/// <param name="url">请求地址</param>
/// <param name="postData">请求数据</param>
/// <returns>字符</returns>
public static string PutResponse(string url, object obj)
{
HttpClient httpClient = new HttpClient(new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.GZip });
HttpResponseMessage response = null;
try
{
//using (HttpClient httpClient = new HttpClient())
//{
httpClient.MaxResponseContentBufferSize = 256000;
httpClient.DefaultRequestHeaders.Add("user-agent", userAgen);
httpClient.CancelPendingRequests();
httpClient.DefaultRequestHeaders.Clear();
string postData = JsonConvertTool.SerializeObject(obj);
HttpContent httpContent = new StringContent(postData);
httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
Task<HttpResponseMessage> taskResponse = httpClient.PostAsync(url, httpContent);
taskResponse.Wait();
response = taskResponse.Result;
//using (HttpResponseMessage response = taskResponse.Result)
//{
//HttpResponseMessage response = httpClient.PutAsync(url, httpContent).Result;
if (response.IsSuccessStatusCode)
{
Task<System.IO.Stream> taskStream = response.Content.ReadAsStreamAsync();
taskStream.Wait();
System.IO.Stream dataStream = taskStream.Result;
System.IO.StreamReader reader = new System.IO.StreamReader(dataStream);
string result = reader.ReadToEnd();
return result;
}
//}
return null;
//}
}
catch
{
return null;
}
finally
{
if (response != null)
{
response.Dispose();
}
if (httpClient != null)
{
httpClient.Dispose(); }
}
} /// <summary>
/// 将Http状态码翻译为对应的中文【暂未使用】
/// </summary>
/// <param name="code">Http状态码</param>
/// <returns>中文解析</returns>
public static string ToChsText(HttpStatusCode code)
{
switch (code)
{
case HttpStatusCode.Continue:
return "请求者应继续进行请求";
case HttpStatusCode.SwitchingProtocols:
return "请求者已要求服务器切换协议,服务器已确认并准备进行切换";
case HttpStatusCode.OK:
return "服务器成功处理了相应请求";
case HttpStatusCode.Created:
return "请求成功且服务器已创建了新的资源";
case HttpStatusCode.Accepted:
return "服务器已接受相应请求,但尚未对其进行处理";
case HttpStatusCode.NonAuthoritativeInformation:
return "服务器已成功处理相应请求,但返回了可能来自另一来源的信息";
case HttpStatusCode.NoContent:
return "服务器已成功处理相应请求,但未返回任何内容";
case HttpStatusCode.ResetContent:
return "服务器已成功处理相应请求,但未返回任何内容,但要求请求者重置文档视图";
case HttpStatusCode.PartialContent:
return "服务器成功处理了部分 GET 请求";
case HttpStatusCode.MultipleChoices:
return "服务器可以根据请求来执行多项操作";
case HttpStatusCode.Moved:
return "请求的网页已永久移动到新位置";
case HttpStatusCode.Redirect:
return "服务器目前正从不同位置的网页响应请求,但请求者应继续使用原有位置来进行以后的请求";
case HttpStatusCode.RedirectMethod:
return "当请求者应对不同的位置进行单独的 GET 请求以检索响应时,服务器会返回此代码";
case HttpStatusCode.NotModified:
return "请求的网页自上次请求后再也没有修改过";
case HttpStatusCode.UseProxy:
return "请求者只能使用代理访问请求的网页";
case HttpStatusCode.Unused:
return "Unused 是未完全指定的 HTTP/1.1 规范的建议扩展";
case HttpStatusCode.RedirectKeepVerb:
return "服务器目前正从不同位置的网页响应请求,但请求者应继续使用原有位置来进行以后的请求";
case HttpStatusCode.BadRequest:
return "服务器未能识别请求";
case HttpStatusCode.Unauthorized:
return "请求要求进行身份验证";
case HttpStatusCode.PaymentRequired:
return "保留 PaymentRequired 以供将来使用";
case HttpStatusCode.Forbidden:
return "服务器拒绝相应请求";
case HttpStatusCode.NotFound:
return "服务器找不到请求的资源";
case HttpStatusCode.MethodNotAllowed:
return "禁用相应请求中所指定的方法";
case HttpStatusCode.NotAcceptable:
return "无法使用相应请求的内容特性来响应请求的网页";
case HttpStatusCode.ProxyAuthenticationRequired:
return "请求者应当使用代理进行授权";
case HttpStatusCode.RequestTimeout:
return "服务器在等待请求时超时";
case HttpStatusCode.Conflict:
return "服务器在完成请求时遇到冲突";
case HttpStatusCode.Gone:
return "请求的资源已被永久删除";
case HttpStatusCode.LengthRequired:
return "服务器不会接受包含无效内容长度标头字段的请求";
case HttpStatusCode.PreconditionFailed:
return "服务器未满足请求者在请求中设置的其中一个前提条件";
case HttpStatusCode.RequestEntityTooLarge:
return "服务器无法处理相应请求,因为请求实体过大,已超出服务器的处理能力";
case HttpStatusCode.RequestUriTooLong:
return "请求的 URI 过长,服务器无法进行处理";
case HttpStatusCode.UnsupportedMediaType:
return "相应请求的格式不受请求页面的支持";
case HttpStatusCode.RequestedRangeNotSatisfiable:
return "如果相应请求是针对网页的无效范围进行的,那么服务器会返回此状态代码";
case HttpStatusCode.ExpectationFailed:
return "服务器未满足“期望”请求标头字段的要求";
case HttpStatusCode.InternalServerError:
return "服务器内部遇到错误,无法完成相应请求";
case HttpStatusCode.NotImplemented:
return "请求的功能在服务器中尚未实现";
case HttpStatusCode.BadGateway:
return "服务器作为网关或代理,从上游服务器收到了无效的响应";
case HttpStatusCode.ServiceUnavailable:
return "目前服务器不可用(由于超载或进行停机维护)";
case HttpStatusCode.GatewayTimeout:
return "服务器作为网关或代理,未及时从上游服务器接收请求";
case HttpStatusCode.HttpVersionNotSupported:
return "服务器不支持相应请求中所用的 HTTP 协议版本";
default:
return "未知Http状态";
}
} } }

  

core net 实现post 跟get的更多相关文章

  1. ASP.NET Core 之 Identity 入门(一)

    前言 在 ASP.NET Core 中,仍然沿用了 ASP.NET里面的 Identity 组件库,负责对用户的身份进行认证,总体来说的话,没有MVC 5 里面那么复杂,因为在MVC 5里面引入了OW ...

  2. .NET Core中的认证管理解析

    .NET Core中的认证管理解析 0x00 问题来源 在新建.NET Core的Web项目时选择“使用个人用户账户”就可以创建一个带有用户和权限管理的项目,已经准备好了用户注册.登录等很多页面,也可 ...

  3. ASP.NET Core 中的那些认证中间件及一些重要知识点

    前言 在读这篇文章之间,建议先看一下我的 ASP.NET Core 之 Identity 入门系列(一,二,三)奠定一下基础. 有关于 Authentication 的知识太广,所以本篇介绍几个在 A ...

  4. .Net Core MVC 网站开发(Ninesky) 2.4、添加栏目与异步方法

    在2.3中完成依赖注入后,这次主要实现栏目的添加功能.按照前面思路栏目有三种类型,常规栏目即可以添加子栏目也可以选择是否添加内容,内容又可以分文章或其他类型,所以还要添加一个模块功能.这次主要实现栏目 ...

  5. ASP.NET Core应用的错误处理[3]:ExceptionHandlerMiddleware中间件如何呈现“定制化错误页面”

    DeveloperExceptionPageMiddleware中间件利用呈现出来的错误页面实现抛出异常和当前请求的详细信息以辅助开发人员更好地进行纠错诊断工作,而ExceptionHandlerMi ...

  6. EntityFramework Core Raw SQL

    前言 本节我们来讲讲EF Core中的原始查询,目前在项目中对于简单的查询直接通过EF就可以解决,但是涉及到多表查询时为了一步到位就采用了原始查询的方式进行.下面我们一起来看看. EntityFram ...

  7. ASP.NET Core MVC/WebAPi 模型绑定探索

    前言 相信一直关注我的园友都知道,我写的博文都没有特别枯燥理论性的东西,主要是当每开启一门新的技术之旅时,刚开始就直接去看底层实现原理,第一会感觉索然无味,第二也不明白到底为何要这样做,所以只有当你用 ...

  8. ASP.NET Core应用的错误处理[2]:DeveloperExceptionPageMiddleware中间件如何呈现“开发者异常页面”

    在<ASP.NET Core应用的错误处理[1]:三种呈现错误页面的方式>中,我们通过几个简单的实例演示了如何呈现一个错误页面,这些错误页面的呈现分别由三个对应的中间件来完成,接下来我们将 ...

  9. Asp.net Core中使用Session

    前言 2017年就这么悄无声息的开始了,2017年对我来说又是特别重要的一年. 元旦放假在家写了个Asp.net Core验证码登录, 做demo的过程中遇到两个小问题,第一是在Asp.net Cor ...

  10. ASP.NET Core 中文文档 第四章 MVC(3.8)视图中的依赖注入

    原文:Dependency injection into views 作者:Steve Smith 翻译:姚阿勇(Dr.Yao) 校对:孟帅洋(书缘) ASP.NET Core 支持在视图中使用 依赖 ...

随机推荐

  1. English trip EM2-LP-1A Hi Teacher:Taylor

    课上内容(Lesson) 词汇(Key Word ) Introduce  vt. 介绍:引进:提出:采用 greet  [ɡrit]  vt. 欢迎,迎接:致敬,致意:映入眼帘  n. (Greet ...

  2. 【洛谷 P1216】【IOI1994】【USACO1.5】数字三角形 Number Triangles

    (如此多的标签qaq) 数字三角形 Number Triangles[传送门] 本来打算当DP练的,没想到写着写着成递推了(汗) 好的没有时间了,我们附个ac代码(改天不写): #include< ...

  3. dijkstra优化

    1, 桶优化最短路, 时间复杂度$O(m+n)$, 空间$O(C)$, $C$为最短路长度 const int N = 1e6+10; int n, m; struct _ {int to,w;}; ...

  4. 『流畅的Python』第9章笔记_对象

    一.Python风格 以一个二元素向量对象为例 import math from array import array class Vector2d: typecode = 'd' def __ini ...

  5. Kubernetes DNS 高阶指南(转发别人 解析很详细)

    转发地址:http://www.jintiankansha.me/t/Js1R84GGAl DNS 是 Kubernetes 的核心功能之一,Kubernetes 通过 kube-dns 或  Cor ...

  6. 6月17 ThinkPHP连接数据库------数据的修改及删除

    1.数据修改操作 save()  实现数据修改,返回受影响的记录条数 具体有两种方式实现数据修改,与添加类似(数组.AR方式) 1.数组方式 a)         $goods = D(“Goods” ...

  7. ubuntu计划任务的编写

    1,首先,我编写的计划任务是在ubunut系统上的.首先我们来认识一下每一个 * 这样子的符号代表什么意思吧! *  *  *  *  * 从左到右: 第1列表示分钟1-59 每分钟用*或者 */1表 ...

  8. Leetcode 860. 柠檬水找零

    860. 柠檬水找零  显示英文描述 我的提交返回竞赛   用户通过次数187 用户尝试次数211 通过次数195 提交次数437 题目难度Easy 在柠檬水摊上,每一杯柠檬水的售价为 5 美元. 顾 ...

  9. Oracle中序列(Sequence)详解

    一 序列定义 序列(SEQUENCE)是序列号生成器,可以为表中的行自动生成序列号,产生一组等间隔的数值(类型为数字).不占用磁盘空间,占用内存. 其主要用途是生成表的主键值,可以在插入语句中引用,也 ...

  10. 1004. Max Consecutive Ones III最大连续1的个数 III

    网址:https://leetcode.com/problems/max-consecutive-ones-iii/ 参考:https://leetcode.com/problems/max-cons ...