身份证号码编码规则及校验位校验算法

算法地址:http://jingyan.baidu.com/article/7f41ececff944a593d095c8c.html

简单验证长度

         /// <summary>
/// 检查身份证基本信息
/// </summary>
/// <returns>结果</returns>
private string CheckAndParse()
{
if (string.IsNullOrWhiteSpace(this.Id))
{
return "身份证号码不能为空";
}
if (this.Id.Length == )
{
return this.ParseCardInfo15();
}
if (this.Id.Length == )
{
return this.ParseCardInfo18();
}
return "身份证号码必须为15位或18位";
}

简单验证

身份证分为2中 18位 OR 15位

验证先用正则表达式进行初步验证 并且取出 身份证上面包含的信息(地区 生日 随机码 性别 尾号)

18位身份证

        /// <summary>
/// 18位身份证
/// </summary>
/// <returns>结果</returns>
private string ParseCardInfo18()
{
const string CardIdParttern = @"(\d{6})(\d{4})(\d{2})(\d{2})(\d{2})(\d{1})([\d,x,X]{1})";
Match match = Regex.Match(this.Id, CardIdParttern);
if (match.Success)
{
this.areaCode = match.Groups[].Value;
string year = match.Groups[].Value;
string month = match.Groups[].Value;
string day = match.Groups[].Value;
this.birthCode = year + month + day;
this.randomCode = match.Groups[].Value;
this.sexCode = char.Parse(match.Groups[].Value);
string verifyCode = match.Groups[].Value.ToUpper(); if (this.ValidateVerifyCode(this.Id.Substring(, ), char.Parse(verifyCode)))
{
try
{
this.Birth = BirthDate.GetBirthDate(year, month, day);
this.Area = AreaCodeMapping.GetArea(this.areaCode);
Sex = GetSex(this.sexCode);
}
catch (System.Exception ex)
{
return ex.Message;
}
return string.Empty;
}
}
return "身份证号码格式错误";
}

18位

15位身份证

         /// <summary>
/// 15位身份证
/// </summary>
/// <returns>结果</returns>
private string ParseCardInfo15()
{
const string CardIdParttern = @"(\d{6})(\d{2})(\d{2})(\d{2})(\d{2})(\d{1})";
Match match = Regex.Match(this.Id, CardIdParttern);
if (match.Success)
{
this.areaCode = match.Groups[].Value;
string year = match.Groups[].Value;
string month = match.Groups[].Value;
string day = match.Groups[].Value;
this.birthCode = year + month + day;
this.randomCode = match.Groups[].Value;
this.sexCode = char.Parse(match.Groups[].Value); try
{
this.Area = AreaCodeMapping.GetArea(this.areaCode);
this.Birth = BirthDate.GetBirthDate(year, month, day);
Sex = GetSex(this.sexCode);
}
catch (System.Exception ex)
{
return ex.Message;
}
return string.Empty;
}
return "身份证号码格式错误";
}

15位

校验代码

 namespace Notify.Solution.Code.IdentityCard
{
/// <summary>
/// 验证类
/// </summary>
public class Validator
{
/// <summary>
/// 验证码
/// </summary>
private readonly char[] verifyCodeMapping = { '', '', 'X', '', '', '', '', '', '', '', '' }; /// <summary>
/// 地区代码
/// </summary>
private string areaCode; /// <summary>
/// 生日
/// </summary>
private string birthCode; /// <summary>
/// 随机
/// </summary>
private string randomCode; /// <summary>
/// 性别
/// </summary>
private char sexCode; /// <summary>
/// Initializes a new instance of the <see cref="Validator"/> class.
/// </summary>
/// <param name="id">Id</param>
public Validator(string id)
{
this.Id = id;
this.Success = false;
this.ErrorMessage = string.Empty;
this.Area = null;
this.Birth = BirthDate.Empty;
this.Sex = Sex.Male;
} /// <summary>
/// 身份证ID
/// </summary>
public string Id { get; private set; } /// <summary>
/// 结果
/// </summary>
public bool Success { get; private set; } /// <summary>
/// 错误信息
/// </summary>
public string ErrorMessage { get; private set; } /// <summary>
/// 区域信息
/// </summary>
public AreaInformation Area { get; private set; } /// <summary>
/// 生日
/// </summary>
public BirthDate Birth { get; private set; } /// <summary>
/// 性别
/// </summary>
public Sex Sex { get; private set; } /// <summary>
/// 执行比较结果
/// </summary>
/// <returns>结果</returns>
public bool Execute()
{
string msg = this.CheckAndParse();
if (string.IsNullOrWhiteSpace(msg))
{
this.ErrorMessage = string.Empty;
this.Success = true;
}
else
{
this.ErrorMessage = msg;
this.Success = false;
}
return this.Success;
} /// <summary>
/// IdentityCard18
/// </summary>
public string IdentityCard18
{
get
{
if (string.IsNullOrWhiteSpace(this.Id))
{
return "身份证号码不能为空";
}
if (this.Success && this.Id.Length == )
{
return this.ToCardInfo18();
}
return this.Id;
}
} /// <summary>
/// ToCardInfo18
/// </summary>
/// <returns>结果</returns>
private string ToCardInfo18()
{
string bodyCode = GetBodyCode(this.areaCode, "" + this.birthCode, this.randomCode, this.sexCode);
char verifyCode = this.GetVerifyCode(bodyCode);
return bodyCode + verifyCode;
} /// <summary>
/// 获取bodyCode
/// </summary>
/// <param name="areaCode">areaCode</param>
/// <param name="birthCode">birthCode</param>
/// <param name="randomCode">randomCode</param>
/// <param name="sexCode">sexCode</param>
/// <returns></returns>
private static string GetBodyCode(string areaCode, string birthCode, string randomCode, char sexCode)
{
return areaCode + birthCode + randomCode + sexCode.ToString();
} /// <summary>
/// 检查身份证基本信息
/// </summary>
/// <returns>结果</returns>
private string CheckAndParse()
{
if (string.IsNullOrWhiteSpace(this.Id))
{
return "身份证号码不能为空";
}
if (this.Id.Length == )
{
return this.ParseCardInfo15();
}
if (this.Id.Length == )
{
return this.ParseCardInfo18();
}
return "身份证号码必须为15位或18位";
} /// <summary>
/// 18位身份证
/// </summary>
/// <returns>结果</returns>
private string ParseCardInfo18()
{
const string CardIdParttern = @"(\d{6})(\d{4})(\d{2})(\d{2})(\d{2})(\d{1})([\d,x,X]{1})";
Match match = Regex.Match(this.Id, CardIdParttern);
if (match.Success)
{
this.areaCode = match.Groups[].Value;
string year = match.Groups[].Value;
string month = match.Groups[].Value;
string day = match.Groups[].Value;
this.birthCode = year + month + day;
this.randomCode = match.Groups[].Value;
this.sexCode = char.Parse(match.Groups[].Value);
string verifyCode = match.Groups[].Value.ToUpper(); if (this.ValidateVerifyCode(this.Id.Substring(, ), char.Parse(verifyCode)))
{
try
{
this.Birth = BirthDate.GetBirthDate(year, month, day);
this.Area = AreaCodeMapping.GetArea(this.areaCode);
Sex = GetSex(this.sexCode);
}
catch (System.Exception ex)
{
return ex.Message;
}
return string.Empty;
}
}
return "身份证号码格式错误";
} /// <summary>
/// 验证验证码
/// </summary>
/// <param name="bodyCode">bodyCode</param>
/// <param name="verifyCode">verifyCode</param>
/// <returns>结果</returns>
private bool ValidateVerifyCode(string bodyCode, char verifyCode)
{
char calculatedVerifyCode = this.GetVerifyCode(bodyCode);
return calculatedVerifyCode == verifyCode;
} /// <summary>
/// 15位身份证
/// </summary>
/// <returns>结果</returns>
private string ParseCardInfo15()
{
const string CardIdParttern = @"(\d{6})(\d{2})(\d{2})(\d{2})(\d{2})(\d{1})";
Match match = Regex.Match(this.Id, CardIdParttern);
if (match.Success)
{
this.areaCode = match.Groups[].Value;
string year = match.Groups[].Value;
string month = match.Groups[].Value;
string day = match.Groups[].Value;
this.birthCode = year + month + day;
this.randomCode = match.Groups[].Value;
this.sexCode = char.Parse(match.Groups[].Value); try
{
this.Area = AreaCodeMapping.GetArea(this.areaCode);
this.Birth = BirthDate.GetBirthDate(year, month, day);
Sex = GetSex(this.sexCode);
}
catch (System.Exception ex)
{
return ex.Message;
}
return string.Empty;
}
return "身份证号码格式错误";
} /// <summary>
/// 获取验证码
/// </summary>
/// <param name="bodyCode">bodyCode</param>
/// <returns>结果</returns>
private char GetVerifyCode(string bodyCode)
{
char[] bodyCodeArray = bodyCode.ToCharArray();
////int sum = 0;
////for (int index = 0; index < bodyCodeArray.Length; index++)
////{
//// sum += int.Parse(bodyCodeArray[index].ToString()) * GetWeight(index);
////}
////return this.verifyCodeMapping[sum % 11];
int sum = bodyCodeArray.Select((t, index) => int.Parse(t.ToString()) * GetWeight(index)).Sum();
return this.verifyCodeMapping[sum % ];
} /// <summary>
/// GetWeight
/// </summary>
/// <param name="index">index</param>
/// <returns>index</returns>
private static int GetWeight(int index)
{
return ( << ( - index)) % ;
} /// <summary>
/// 获取性别
/// </summary>
/// <param name="sexCode">性别代码</param>
/// <returns>性别</returns>
private static Sex GetSex(char sexCode)
{
return ((int)sexCode) % == ? Sex.Female : Sex.Male;
}
} /// <summary>
/// 生日
/// </summary>
public struct BirthDate
{
/// <summary>
/// 年
/// </summary>
private readonly string year; /// <summary>
/// 月
/// </summary>
private readonly string month; /// <summary>
/// 日
/// </summary>
private readonly string day; /// <summary>
/// 默认
/// </summary>
public static BirthDate Empty
{
get { return new BirthDate("", "", ""); }
} /// <summary>
/// Initializes a new instance of the <see cref="BirthDate"/> struct.
/// </summary>
/// <param name="year">年</param>
/// <param name="month">月</param>
/// <param name="day">日</param>
public BirthDate(string year, string month, string day)
{
this.year = year;
this.month = month;
this.day = day;
} /// <summary>
/// 获取生日
/// </summary>
/// <param name="year">年</param>
/// <param name="month">月</param>
/// <param name="day">日</param>
/// <returns>结果</returns>
public static BirthDate GetBirthDate(string year, string month, string day)
{
DateTime date;
if (DateTime.TryParse(string.Format("{0}-{1}-{2}", year, month, day), out date))
{
return new BirthDate(year, month, day);
}
throw new System.Exception("日期不存在");
} /// <summary>
/// 年
/// </summary>
public string Year
{
get { return this.year; }
} /// <summary>
/// 年
/// </summary>
public string Month
{
get { return this.month; }
} /// <summary>
/// 日
/// </summary>
public string Day
{
get { return this.day; }
} /// <summary>
/// 重写ToString
/// </summary>
/// <returns>结果</returns>
public override string ToString()
{
return string.Format("{0}年{1}月{2}日", this.year, this.month, this.day);
} /// <summary>
/// 重写ToString
/// </summary>
/// <param name="separator">separator</param>
/// <returns>结果</returns>
public string ToString(string separator)
{
return string.Format("{1}{0}{2}{0}{3}", separator, this.year, this.month, this.day);
}
} /// <summary>
/// 性别
/// </summary>
public enum Sex
{
/// <summary>
/// 男
/// </summary>
Male, /// <summary>
/// 女
/// </summary>
Female
}
}

读取地区代码

 namespace Notify.Solution.Code.IdentityCard
{
/// <summary>
/// 区域配置
/// </summary>
public class AreaCodeMapping
{
/// <summary>
/// 区域字典
/// </summary>
private static readonly Dictionary<string, Area> areas; /// <summary>
/// Initializes static members of the <see cref="AreaCodeMapping"/> class.
/// </summary>
static AreaCodeMapping()
{
areas = LoadAreaInfo();
} /// <summary>
/// 加载信息
/// </summary>
/// <returns>区域信息</returns>
private static Dictionary<string, Area> LoadAreaInfo()
{
XmlDocument doc = LoadXmlDocument("AreaCodes.xml");
XmlNode areasNode = doc.SelectSingleNode("AreaCode");
if (areasNode != null)
{
XmlNodeList provinceNodeList = areasNode.ChildNodes;
return LoadProvinces(provinceNodeList);
} return null;
} /// <summary>
/// 加载XML
/// </summary>
/// <param name="fileName">文件名</param>
/// <returns>XmlDocument</returns>
private static XmlDocument LoadXmlDocument(string fileName)
{
var declaringType = MethodBase.GetCurrentMethod().DeclaringType;
if (declaringType != null)
{
string resourceName = declaringType.Namespace + "." + fileName;
Assembly assembly = Assembly.GetExecutingAssembly();
Stream stream = assembly.GetManifestResourceStream(resourceName);
XmlDocument result = new XmlDocument();
if (stream != null)
{
result.Load(stream);
}
return result;
}
return null;
} /// <summary>
/// 解析XML节点
/// </summary>
/// <param name="provinceNodeList">provinceNodeList</param>
/// <returns>结果</returns>
private static Dictionary<string, Area> LoadProvinces(XmlNodeList provinceNodeList)
{
Dictionary<string, Area> result = new Dictionary<string, Area>();
foreach (XmlNode provinceNode in provinceNodeList)
{
string code = GetAttribute(provinceNode, "code");
string name = GetAttribute(provinceNode, "name");
Area province = new Area(code, name, null);
var cities = LoadCities(province, provinceNode.ChildNodes);
foreach (var city in cities)
{
province.AppendChild(city);
}
result.Add(code, province);
}
return result;
} /// <summary>
/// 加载城市
/// </summary>
/// <param name="province">省</param>
/// <param name="cityNodeList">节点</param>
/// <returns>结果</returns>
private static IEnumerable<Area> LoadCities(Area province, XmlNodeList cityNodeList)
{
List<Area> result = new List<Area>();
if (cityNodeList != null)
{
foreach (XmlNode cityNode in cityNodeList)
{
string code = GetAttribute(cityNode, "code");
string name = GetAttribute(cityNode, "name");
Area city = new Area(code, name, province);
var counties = loadCounties(city, cityNode.ChildNodes);
foreach (var county in counties)
{
city.AppendChild(county);
}
result.Add(city);
}
}
return result;
} /// <summary>
/// 加载区域
/// </summary>
/// <param name="city">市</param>
/// <param name="countyNodeList">节点</param>
/// <returns>结果</returns>
private static IEnumerable<Area> loadCounties(Area city, XmlNodeList countyNodeList)
{
List<Area> result = new List<Area>();
if (countyNodeList != null)
{
foreach (XmlNode countyNode in countyNodeList)
{
string code = GetAttribute(countyNode, "code");
string name = GetAttribute(countyNode, "name");
Area county = new Area(code, name, city);
result.Add(county);
}
}
return result;
} /// <summary>
/// 获取节点属性
/// </summary>
/// <param name="node">node</param>
/// <param name="attributeName">attributeName</param>
/// <returns>结果</returns>
private static string GetAttribute(XmlNode node, string attributeName)
{
if (node.Attributes != null)
{
XmlAttribute attribute = node.Attributes[attributeName];
return attribute == null ? string.Empty : attribute.Value;
}
return string.Empty;
} /// <summary>
/// 获取区域信息
/// </summary>
/// <param name="areaCode">区域代码</param>
/// <returns>结果</returns>
public static AreaInformation GetArea(string areaCode)
{
Area targetArea = null;
if (!string.IsNullOrWhiteSpace(areaCode) && areaCode.Length == )
{
string provinceCode = areaCode.Substring(, );
if (areas.ContainsKey(provinceCode))
{
var province = areas[provinceCode];
string cityCode = areaCode.Substring(, );
if (province.ContainsChild(cityCode))
{
var city = province.GetChild(cityCode);
string countyCode = areaCode.Substring();
if (city.ContainsChild(countyCode))
{
targetArea = city.GetChild(countyCode);
}
else
{
targetArea = city;
}
}
else if (province.ContainsChild(areaCode.Substring()))
{
targetArea = province.GetChild(areaCode.Substring());
}
else
{
targetArea = province;
}
}
}
return targetArea == null ? null : targetArea.ToAreaInformation();
}
} /// <summary>
/// 区域
/// </summary>
public class Area
{
/// <summary>
/// 子区域
/// </summary>
private readonly Dictionary<string, Area> childrenDic; /// <summary>
/// 区域集
/// </summary>
private readonly List<Area> childrenList; /// <summary>
/// Initializes a new instance of the <see cref="Area"/> class.
/// </summary>
/// <param name="code">代码</param>
/// <param name="name">名称</param>
/// <param name="parent">父区域</param>
internal Area(string code, string name, Area parent)
{
this.Info = new CodeNameMapping(code, name);
this.Parent = parent;
this.childrenDic = new Dictionary<string, Area>();
this.childrenList = new List<Area>();
} /// <summary>
/// 代码名称映射信息
/// </summary>
public CodeNameMapping Info
{
get;
private set;
} /// <summary>
/// 父区域
/// </summary>
public Area Parent
{
get;
private set;
} /// <summary>
/// 子区域
/// </summary>
public ReadOnlyCollection<Area> Children
{
get
{
return this.childrenList.AsReadOnly();
}
} /// <summary>
/// 区域集是否包含
/// </summary>
/// <param name="code">代码</param>
/// <returns>结果</returns>
internal bool ContainsChild(string code)
{
return this.childrenDic.ContainsKey(code);
} /// <summary>
/// 获取区域
/// </summary>
/// <param name="code">代码</param>
/// <returns>区域</returns>
internal Area GetChild(string code)
{
return this.childrenDic[code];
} /// <summary>
/// 父亲区域
/// </summary>
internal Area TopParent
{
get
{
return this.Parent == null ? this : this.Parent.TopParent;
}
} /// <summary>
/// 添加子区域
/// </summary>
/// <param name="child">子节点</param>
internal void AppendChild(Area child)
{
if (!this.childrenDic.ContainsKey(child.Info.Code))
{
this.childrenDic.Add(child.Info.Code, child);
this.childrenList.Add(child);
}
} /// <summary>
/// 区域信息转化
/// </summary>
/// <returns>区域信息</returns>
internal AreaInformation ToAreaInformation()
{
CodeNameMapping province = this.TopParent.Info;
CodeNameMapping city = default(CodeNameMapping);
CodeNameMapping county = default(CodeNameMapping);
if (this.Parent != null)
{
if (this.Parent.Info == province)
{
city = this.Info;
}
else
{
city = this.Parent.Info;
county = this.Info;
}
}
return new AreaInformation(province, city, county);
}
} /// <summary>
/// 区域信息
/// </summary>
public class AreaInformation
{
/// <summary>
/// Initializes a new instance of the <see cref="AreaInformation"/> class.
/// </summary>
/// <param name="province">省</param>
/// <param name="city">市</param>
/// <param name="county">区</param>
public AreaInformation(CodeNameMapping province, CodeNameMapping city, CodeNameMapping county)
{
this.Province = province;
this.City = city;
this.County = county;
} /// <summary>
/// 代码
/// </summary>
public string Code
{
get
{
return this.Province.Code + this.City.Code + this.County.Code;
}
} /// <summary>
/// 省
/// </summary>
public CodeNameMapping Province
{
get;
private set;
} /// <summary>
/// 市
/// </summary>
public CodeNameMapping City
{
get;
private set;
} /// <summary>
/// 区
/// </summary>
public CodeNameMapping County
{
get;
private set;
} /// <summary>
/// 名称
/// </summary>
public string FullName
{
get
{
return this.Province.Name + this.City.Name + this.County.Name;
}
} /// <summary>
/// 重写ToString
/// </summary>
/// <returns>结果</returns>
public override string ToString()
{
return this.FullName;
}
} /// <summary>
/// 代码名称映射
/// </summary>
public struct CodeNameMapping
{
/// <summary>
/// 代码
/// </summary>
private readonly string code; /// <summary>
/// 名称
/// </summary>
private readonly string name; /// <summary>
/// Initializes a new instance of the <see cref="CodeNameMapping"/> struct.
/// </summary>
/// <param name="code">代码</param>
/// <param name="name">名称</param>
internal CodeNameMapping(string code, string name)
{
this.code = code;
this.name = name;
} /// <summary>
/// 代码
/// </summary>
public string Code
{
get { return this.code; }
} /// <summary>
/// 名称
/// </summary>
public string Name
{
get { return this.name; }
} /// <summary>
/// 重写比较
/// </summary>
/// <param name="obj">对象</param>
/// <returns>结果</returns>
public override bool Equals(object obj)
{
if (obj != null && obj is CodeNameMapping)
{
return ((CodeNameMapping)obj).Code == this.Code;
}
return false;
} /// <summary>
/// GetHashCode
/// </summary>
/// <returns>HashCode</returns>
public override int GetHashCode()
{
return this.Code.GetHashCode();
} /// <summary>
/// 相等比较器
/// </summary>
/// <param name="left">left</param>
/// <param name="right">right</param>
/// <returns>结果</returns>
public static bool operator ==(CodeNameMapping left, CodeNameMapping right)
{
return left.Code != right.Code;
} /// <summary>
/// 不相等比较器
/// </summary>
/// <param name="left">left</param>
/// <param name="right">right</param>
/// <returns>结果</returns>
public static bool operator !=(CodeNameMapping left, CodeNameMapping right)
{
return left.Code != right.Code;
}
}
}

xml配置文件

下载地址

测试方法

         private static void Validator()
{
// 正确的
Validator v = new Validator("");
var rel = v.Execute(); // 错误的 更改第5位数
Validator v1 = new Validator("");
var rel1 = v1.Execute();
}

js验证点这里

.NET身份证验证的更多相关文章

  1. 身份证验证JS代码

    身份证验证JS程序function checkidcardfun(code) { var city = {11: "北京", 12: "天津", 13: &qu ...

  2. java身份证验证

    import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; impor ...

  3. jQuery身份证验证插件

    jQuery身份证验证插件 /*! * jQuery isIDCard Plugin v1.0.0 * http://www.cnblogs.com/cssfirefly/p/5629561.html ...

  4. java对身份证验证及正则表达式解析

    原文地址:http://www.cnblogs.com/zhongshengzhen/ java对身份证验证及正则表达式解析 package service; import java.text.Par ...

  5. Jsp注册页面身份证验证

    <!--身份证验证 --><script type="text/javascript">function isCardNo(Idcardnumber) { ...

  6. C#实现中国身份证验证问题

    C#中国身份证验证,包括省份验证和校验码验证,符合GB11643-1999标准...   今天写的 C#中国身份证验证,包括省份验证和校验码验证,符合GB11643-1999标准... 理论部分: 1 ...

  7. 【NumberValidators】大陆身份证验证

    需要说明的是这里的大陆身份证识别并不是公安局联网的识别,而是按国标GB 11643进行的验证,所以其验证结果只能说符合国标规范,但不能保证该身份证一定真实存在,如果你实际需求是希望身份证一定真实存在, ...

  8. Java正则表达式实现港、澳、台身份证验证

    最近由于业务的要求,需要进行港.澳.台人员身份证验证,现在直接上代码,经供参考学习,也为自己积累一些工具类: package com.qiu.validate; public class regexV ...

  9. js邮箱验证,身份证验证,正则表达式

    邮箱验证: html部分: 邮箱验证:<input type="text" id="mail" value="" / onkeyup= ...

  10. Java基础之身份证验证

    //简约版package test; import java.util.Scanner; public class ID { /** * 匹配算法 : 1) 得到17位身份证号码与下面给出的17位 2 ...

随机推荐

  1. logistics回归

    logistic回归的基本思想 logistic回归是一种分类方法,用于两分类问题.其基本思想为: a. 寻找合适的假设函数,即分类函数,用以预测输入数据的判断结果: b. 构造代价函数,即损失函数, ...

  2. LeetCode Python 位操作 1

    Python 位操作: 按位与 &, 按位或 | 体会不到 按位异或 ^ num ^ num = 0 左移 << num << 1 == num * 2**1 右移 & ...

  3. jquery.lazyload 使用

    1.引用js <script src="jquery.js" type="text/javascript"></script> < ...

  4. Vue项目使用AES做加密

    1.先在vue项目中安装crypto-js 2.在项目中新建一个utils.js文件 3.utils.js文件中的内容 /** * 工具类 */ import Vue from 'vue' impor ...

  5. SV中的Interface和Program

    Interface:SV中新定义的接口方式,用来简化接口连接,使用时注意在module或program之外定义interface,然后通过'include来添加进工程. interface  arb_ ...

  6. liunx anacoda 安装pyltp

    anacoda 默认的gcc是4.7需要更新 https://anaconda.org/nlesc/gcc 更新之后再安装即可. 报错: /usr/lib64/libstdc++.so.6: vers ...

  7. Object-C-属性参数

    assign:默认参数setter 方法不会引起引用计数的变化 retain:setter方法首先释放旧的对象,将旧对象的值赋予输入对象,再提高输入对象的引用计数为1 copy:setter 方法首先 ...

  8. C++ Word Count 发布程序

    前段时间,模仿 Linux 系统下的 wc 程序,在 Windows 系统环境下使用 C/C++ 实现了一个相似的 WC 程序,只不过有针对性,针对的是 C/C++,Java 等风格的源代码文件. 此 ...

  9. js dom 操作技巧

    1.创建元素 创建元素:document.createElement() 使用document.createElement()可以创建新元素.这个方法只接受一个参数,即要创建元素的标签名.这个标签名在 ...

  10. 禁止火狐浏览器缓存input标签方法

    禁止火狐浏览器缓存input标签方法 问题1:在火狐浏览器里,云平台的输入框.选项框.勾选框…填写之后按F5刷新页面,之前填的东西会保留着,其它浏览器不会火狐强制刷新用Ctrl + F5 浏览器自动保 ...