Graphviz程序命令行调用

命令行调用

所有的Graphviz程序都具有相似的命令行调用方式:

cmd [ flags] [input files]

如果没有指定输入文件路径,程序从标准输入(stdin)中读取。

参数设置:

-Gname[=value]

设置图的属性,缺省值 value = true

-Nname[=value]

学习Graphviz绘图

简介

graphviz是贝尔实验室开发的一个开源的工具包,它使用一个特定的DSL(领域特定语言):dot作为脚本语言,然后使用布局引擎来解析此脚本,并完成自动布局。graphviz提供丰富的导出格式,如常用的图片格式,SVG,PDF格式等。

C# XML操作封装

利用XPath操作XML文档。

//下面列出了最有用的路径表达式:
//  nodename	 选取此节点的所有子节点。
//  /            从根节点选取。
//  //	         从匹配选择的当前节点选择文档中的节点,而不考虑它们的位置。
//  .	         选取当前节点。
//  ..	         选取当前节点的父节点。
//  @	         选取属性

///<summary>
/// xml解析工具
///</summary>
public class XmlTool
{
    #region XML文档节点查询和读取
    ///<summary>
    /// 选择匹配XPath表达式的第一个节点XmlNode.
    ///</summary>
    ///<param name="xmlFileName">XML文档完全文件名(包含物理路径)</param>
    ///<param name="xpath">要匹配的XPath表达式(例如:"//节点名//子节点名")</param>
    ///<returns>返回XmlNode</returns>
    public static XmlNode GetXmlNodeByXpath(string xmlFileName, string xpath)
    {
        XmlDocument xmlDoc = new XmlDocument();
        try
        {
            //加载XML文档
            xmlDoc.Load(xmlFileName);
            XmlNode xmlNode = xmlDoc.SelectSingleNode(xpath);
            return xmlNode;
        }
        catch (Exception ex)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(typeof(XmlTool));
            log.Error("函数GetXmlNodeByXpath,总参数2,错误信息->" + ex.Message);
            log.Error("函数GetXmlNodeByXpath,参数1,xmlFileName->" + xmlFileName);
            log.Error("函数GetXmlNodeByXpath,参数2,xpath->" + xpath);
            return null;
        }
    }

    ///<summary>
    /// 选择匹配XPath表达式的节点列表XmlNodeList.
    ///</summary>
    ///<param name="xmlFileName">XML文档完全文件名(包含物理路径)</param>
    ///<param name="xpath">要匹配的XPath表达式(例如:"//节点名//子节点名")</param>
    ///<returns>返回XmlNodeList</returns>
    public static XmlNodeList GetXmlNodeListByXpath(string xmlFileName, string xpath)
    {
        XmlDocument xmlDoc = new XmlDocument();
        try
        {
            xmlDoc.Load(xmlFileName); //加载XML文档
            XmlNodeList xmlNodeList = xmlDoc.SelectNodes(xpath);
            return xmlNodeList;
        }
        catch (Exception ex)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(typeof(XmlTool));
            log.Error("函数GetXmlNodeListByXpath,总参数2,错误信息->" + ex.Message);
            log.Error("函数GetXmlNodeListByXpath,参数1,xmlFileName->" + xmlFileName);
            log.Error("函数GetXmlNodeListByXpath,参数2,xpath->" + xpath);
            return null;
        }
    }

    ///<summary>
    /// 选择匹配XPath表达式的第一个节点的匹配xmlAttributeName的属性XmlAttribute.
    ///</summary>
    ///<param name="xmlFileName">XML文档完全文件名(包含物理路径)</param>
    ///<param name="xpath">要匹配的XPath表达式(例如:"//节点名//子节点名</param>
    ///<param name="xmlAttributeName">要匹配xmlAttributeName的属性名称</param>
    ///<returns>返回xmlAttributeName</returns>
    public static XmlAttribute GetXmlAttribute(string xmlFileName, string xpath, string xmlAttributeName)
    {
        XmlDocument xmlDoc = new XmlDocument();
        XmlAttribute xmlAttribute = null;
        try
        {
            //加载XML文档
            xmlDoc.Load(xmlFileName);
            XmlNode xmlNode = xmlDoc.SelectSingleNode(xpath);
            if (xmlNode != null)
            {
                if (xmlNode.Attributes.Count > 0)
                {
                    xmlAttribute = xmlNode.Attributes[xmlAttributeName];
                }
            }
        }
        catch (Exception ex)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(typeof(XmlTool));
            log.Error("函数GetXmlAttribute,总参数3,错误信息->" + ex.Message);
            log.Error("函数GetXmlAttribute,参数1,xmlFileName->" + xmlFileName);
            log.Error("函数GetXmlAttribute,参数2,xpath->" + xpath);
            log.Error("函数GetXmlAttribute,参数3,xmlAttributeName->" + xmlAttributeName);
            return null;
        }
        return xmlAttribute;
    }

    public static XmlAttribute GetSpecialAttributeValue(string xmlFileName, string attributeName)
    {
        XmlDocument xmlDoc = new XmlDocument();
        XmlAttribute xmlAttribute = null;
        try
        {
            //加载XML文档
            xmlDoc.Load(xmlFileName);
            XmlNode xmlNode = xmlDoc.SelectSingleNode("/");
            if (xmlNode != null)
            {
                XmlNode node = xmlNode.LastChild;
                if (node.Attributes.Count > 0)
                {
                    xmlAttribute = node.Attributes[attributeName];
                }
            }
        }
        catch (Exception ex)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(typeof(XmlTool));
            log.Error("函数GetSpecialAttributeValue,总参数2,错误信息->" + ex.Message);
            log.Error("函数GetSpecialAttributeValue,参数1,xmlFileName->" + xmlFileName);
            log.Error("函数GetSpecialAttributeValue,参数2,attributeName->" + attributeName);
            return null;
        }
        return xmlAttribute;
    }

    #endregion

    #region XML文档创建和节点或属性的添加、修改
    ///<summary>
    /// 创建一个XML文档
    ///</summary>
    ///<param name="xmlFileName">XML文档完全文件名(包含物理路径)</param>
    ///<param name="rootNodeName">XML文档根节点名称(须指定一个根节点名称)</param>
    ///<param name="version">XML文档版本号(必须为:"1.0")</param>
    ///<param name="encoding">XML文档编码方式</param>
    ///<param name="standalone">该值必须是"yes"或"no",如果为null,Save方法不在XML声明上写出独立属性</param>
    ///<returns>成功返回true,失败返回false</returns>
    public static bool CreateXmlDocument(string xmlFileName, string rootNodeName, string version, string encoding, string standalone)
    {
        // 文件路径,版本号,根节点名不能为空
        if (string.IsNullOrEmpty(xmlFileName) ||
                string.IsNullOrEmpty(rootNodeName) ||
                string.IsNullOrEmpty(version))
        {
            return false;
        }

        bool isSuccess = false;
        try
        {
            XmlDocument xmlDoc = new XmlDocument();
            XmlDeclaration xmlDeclaration = xmlDoc.CreateXmlDeclaration(version, encoding, standalone);
            XmlNode root = xmlDoc.CreateElement(rootNodeName);
            xmlDoc.AppendChild(xmlDeclaration);
            xmlDoc.AppendChild(root);
            xmlDoc.Save(xmlFileName);
            isSuccess = true;
        }
        catch (Exception ex)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(typeof(XmlTool));
            log.Error("函数CreateXmlDocument,总参数5,错误信息->" + ex.Message);
            log.Error("函数CreateXmlDocument,参数1,xmlFileName->" + xmlFileName);
            log.Error("函数CreateXmlDocument,参数2,rootNodeName->" + rootNodeName);
            log.Error("函数CreateXmlDocument,参数3,version->" + version);
            log.Error("函数CreateXmlDocument,参数4,encoding->" + encoding);
            log.Error("函数CreateXmlDocument,参数5,standalone->" + standalone);
        }
        return isSuccess;
    }


    /// <summary>
    /// 依据匹配XPath表达式的第一个节点来创建它的子节点(如果此节点已存在则追加一个新的同名节点)
    /// </summary>
    /// <param name="xmlFileName">XML文档完全文件名(包含物理路径)</param>
    /// <param name="xpath">要匹配的XPath表达式(例如:"//节点名//子节点名</param>
    /// <param name="xmlNodeName">要匹配xmlNodeName的节点名称</param>
    /// <param name="innerText">节点文本值</param>
    /// <param name="listAttribute">要添加的xmlAttributeName的属性</param>
    /// <returns>成功返回true,失败返回false</returns>
    public static bool CreateXmlNodeByXPath(string xmlFileName, string xpath, string xmlNodeName, string innerText, List<KeyValuePair<string, string>> listAttribute)
    {
        if(string.IsNullOrEmpty(xmlFileName) ||
                string.IsNullOrEmpty(xpath) ||
                string.IsNullOrEmpty(xmlNodeName))
        {
            return false;
        }

        bool isSuccess = false;
        XmlDocument xmlDoc = new XmlDocument();
        try
        {
            //加载XML文档
            xmlDoc.Load(xmlFileName);
            XmlNode xmlNode = xmlDoc.SelectSingleNode(xpath);
            if (xmlNode != null)
            {
                //存不存在此节点都创建
                XmlElement subElement = xmlDoc.CreateElement(xmlNodeName);
                subElement.InnerText = (innerText == null ? "" : innerText);

                //如果属性和值参数都不为空则在此新节点上新增属性
                if (null != listAttribute)
                {
                    foreach (KeyValuePair<string, string> xmlAttr in listAttribute)
                    {
                        if (!string.IsNullOrEmpty(xmlAttr.Key) && !string.IsNullOrEmpty(xmlAttr.Value))
                        {
                            XmlAttribute xmlAttribute = xmlDoc.CreateAttribute(xmlAttr.Key);
                            xmlAttribute.Value = xmlAttr.Value;
                            subElement.Attributes.Append(xmlAttribute);
                        }
                    }
                }
                xmlNode.AppendChild(subElement);
            }
            //保存到XML文档
            xmlDoc.Save(xmlFileName);
            isSuccess = true;
        }
        catch (Exception ex)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(typeof(XmlTool));
            log.Error("函数CreateXmlNodeByXPath,总参数5,错误信息->" + ex.Message);
            log.Error("函数CreateXmlNodeByXPath,参数1,xmlFileName->" + xmlFileName);
            log.Error("函数CreateXmlNodeByXPath,参数2,xpath->" + xpath);
            log.Error("函数CreateXmlNodeByXPath,参数3,xmlNodeName->" + xmlNodeName);
            log.Error("函数CreateXmlNodeByXPath,参数4,innerText->" + innerText);
            log.Error("函数CreateXmlNodeByXPath,参数5,listAttribute为list");
        }
        return isSuccess;
    }

    ///<summary>
    /// 依据匹配XPath表达式的第一个节点来创建或更新它的子节点(如果节点存在则更新,不存在则创建)
    ///</summary>
    ///<param name="xmlFileName">XML文档完全文件名(包含物理路径)</param>
    ///<param name="xpath">要匹配的XPath表达式(例如:"//节点名//子节点名</param>
    ///<param name="xmlNodeName">要匹配xmlNodeName的节点名称</param>
    ///<param name="innerText">节点文本值</param>
    ///<returns>成功返回true,失败返回false</returns>
    public static bool CreateOrUpdateXmlNodeByXPath(string xmlFileName, string xpath, string xmlNodeName, string innerText)
    {
        if (string.IsNullOrEmpty(xmlFileName) ||
                string.IsNullOrEmpty(xpath) ||
                string.IsNullOrEmpty(xmlNodeName))
        {
            return false;
        }

        bool isSuccess = false;
        //标识节点是否存在
        bool isExistsNode = false;
        XmlDocument xmlDoc = new XmlDocument();
        try
        {
            xmlDoc.Load(xmlFileName);
            XmlNode xmlNode = xmlDoc.SelectSingleNode(xpath);
            if (xmlNode != null)
            {
                //遍历xpath节点下的所有子节点
                foreach (XmlNode node in xmlNode.ChildNodes)
                {
                    if (node.Name.ToLower() == xmlNodeName.ToLower())
                    {
                        //存在此节点则更新
                        node.InnerText = (innerText == null ? "" : innerText);
                        isExistsNode = true;
                        break;
                    }
                }

                if (!isExistsNode)
                {
                    //不存在此节点则创建
                    XmlElement subElement = xmlDoc.CreateElement(xmlNodeName);
                    subElement.InnerXml = innerText;
                    xmlNode.AppendChild(subElement);
                }
            }
            xmlDoc.Save(xmlFileName); //保存到XML文档
            isSuccess = true;
        }
        catch (Exception ex)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(typeof(XmlTool));
            log.Error("函数CreateXmlNodeByXPath,总参数4,错误信息->" + ex.Message);
            log.Error("函数CreateXmlNodeByXPath,参数1,xmlFileName->" + xmlFileName);
            log.Error("函数CreateXmlNodeByXPath,参数2,xpath->" + xpath);
            log.Error("函数CreateXmlNodeByXPath,参数3,xmlNodeName->" + xmlNodeName);
            log.Error("函数CreateXmlNodeByXPath,参数4,innerText->" + innerText);
        }
        return isSuccess;
    }

    ///<summary>
    /// 依据匹配XPath表达式的第一个节点来创建或更新它的属性(如果属性存在则更新,不存在则创建)
    ///</summary>
    ///<param name="xmlFileName">XML文档完全文件名(包含物理路径)</param>
    ///<param name="xpath">要匹配的XPath表达式(例如:"//节点名//子节点名</param>
    ///<param name="xmlAttributeName">要匹配xmlAttributeName的属性名称</param>
    ///<param name="value">属性值</param>
    ///<returns>成功返回true,失败返回false</returns>
    public static bool CreateOrUpdateXmlAttributeByXPath(string xmlFileName, string xpath, string xmlAttributeName, string value)
    {
        if (string.IsNullOrEmpty(xmlFileName) ||
                string.IsNullOrEmpty(xpath) ||
                string.IsNullOrEmpty(xmlAttributeName))
        {
            return false;
        }

        bool isSuccess = false;
        bool isExistsAttribute = false;//标识属性是否存在
        XmlDocument xmlDoc = new XmlDocument();
        try
        {
            xmlDoc.Load(xmlFileName); //加载XML文档
            XmlNode xmlNode = xmlDoc.SelectSingleNode(xpath);
            if (xmlNode != null)
            {
                //遍历xpath节点中的所有属性
                foreach (XmlAttribute attribute in xmlNode.Attributes)
                {
                    if (attribute.Name.ToLower() == xmlAttributeName.ToLower())
                    {
                        //节点中存在此属性则更新
                        attribute.Value = value;
                        isExistsAttribute = true;
                        break;
                    }
                }
                if (!isExistsAttribute)
                {
                    //节点中不存在此属性则创建
                    XmlAttribute xmlAttribute = xmlDoc.CreateAttribute(xmlAttributeName);
                    xmlAttribute.Value = value;
                    xmlNode.Attributes.Append(xmlAttribute);
                }
            }
            xmlDoc.Save(xmlFileName); //保存到XML文档
            isSuccess = true;
        }
        catch (Exception ex)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(typeof(XmlTool));
            log.Error("函数CreateOrUpdateXmlAttributeByXPath,总参数4,错误信息->" + ex.Message);
            log.Error("函数CreateOrUpdateXmlAttributeByXPath,参数1,xmlFileName->" + xmlFileName);
            log.Error("函数CreateOrUpdateXmlAttributeByXPath,参数2,xpath->" + xpath);
            log.Error("函数CreateOrUpdateXmlAttributeByXPath,参数3,xmlAttributeName->" + xmlAttributeName);
            log.Error("函数CreateOrUpdateXmlAttributeByXPath,参数4,value->" + value);
        }
        return isSuccess;
    }

    ///<summary>
    /// 修改匹配XPath表达式的第一个节点中的对应得属性
    ///</summary>
    ///<param name="xmlFileName">XML文档完全文件名(包含物理路径)</param>
    ///<param name="xpath">要匹配的XPath表达式(例如:"//节点名//子节点名</param>
    ///<returns>成功返回true,失败返回false</returns>
    public static bool ModifyXmlAttributeByXPath(string xmlFileName, string xpath, string attributeName, string attributeValue)
    {
        if (string.IsNullOrEmpty(xmlFileName) || string.IsNullOrEmpty(xpath) || string.IsNullOrEmpty(attributeName))
        {
            return false;
        }

        bool isSuccess = false;
        XmlDocument xmlDoc = new XmlDocument();
        try
        {
            xmlDoc.Load(xmlFileName); //加载XML文档
            XmlNode xmlNode = xmlDoc.SelectSingleNode(xpath);
            if (xmlNode != null)
            {
                xmlNode.Attributes[attributeName].Value = attributeValue;
            }
            xmlDoc.Save(xmlFileName); //保存到XML文档
            isSuccess = true;
        }
        catch (Exception ex)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(typeof(XmlTool));
            log.Error("函数ModifyXmlAttributeByXPath,总参数2,错误信息->" + ex.Message);
            log.Error("函数ModifyXmlAttributeByXPath,参数1,xmlFileName->" + xmlFileName);
            log.Error("函数ModifyXmlAttributeByXPath,参数2,xpath->" + xpath);
        }
        return isSuccess;
    }

    #endregion

    #region XML文档节点或属性的删除
    ///<summary>
    /// 删除匹配XPath表达式的第一个节点(节点中的子元素同时会被删除)
    ///</summary>
    ///<param name="xmlFileName">XML文档完全文件名(包含物理路径)</param>
    ///<param name="xpath">要匹配的XPath表达式(例如:"//节点名//子节点名</param>
    ///<returns>成功返回true,失败返回false</returns>
    public static bool DeleteXmlNodeByXPath(string xmlFileName, string xpath)
    {
        if (string.IsNullOrEmpty(xmlFileName) || string.IsNullOrEmpty(xpath))
        {
            return false;
        }

        bool isSuccess = false;
        XmlDocument xmlDoc = new XmlDocument();
        try
        {
            xmlDoc.Load(xmlFileName); //加载XML文档
            XmlNode xmlNode = xmlDoc.SelectSingleNode(xpath);
            if (xmlNode != null)
            {
                //删除节点
                xmlNode.ParentNode.RemoveChild(xmlNode);
            }
            xmlDoc.Save(xmlFileName); //保存到XML文档
            isSuccess = true;
        }
        catch (Exception ex)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(typeof(XmlTool));
            log.Error("函数DeleteXmlNodeByXPath,总参数2,错误信息->" + ex.Message);
            log.Error("函数DeleteXmlNodeByXPath,参数1,xmlFileName->" + xmlFileName);
            log.Error("函数DeleteXmlNodeByXPath,参数2,xpath->" + xpath);
        }
        return isSuccess;
    }

    ///<summary>
    /// 删除匹配XPath表达式的第一个节点中的匹配参数xmlAttributeName的属性
    ///</summary>
    ///<param name="xmlFileName">XML文档完全文件名(包含物理路径)</param>
    ///<param name="xpath">要匹配的XPath表达式(例如:"//节点名//子节点名</param>
    ///<param name="xmlAttributeName">要删除的xmlAttributeName的属性名称</param>
    ///<returns>成功返回true,失败返回false</returns>
    public static bool DeleteXmlAttributeByXPath(string xmlFileName, string xpath, string xmlAttributeName)
    {
        if (string.IsNullOrEmpty(xmlFileName) || string.IsNullOrEmpty(xpath) || string.IsNullOrEmpty(xpath))
        {
            return false;
        }

        bool isSuccess = false;
        bool isExistsAttribute = false;
        XmlDocument xmlDoc = new XmlDocument();
        try
        {
            xmlDoc.Load(xmlFileName); //加载XML文档
            XmlNode xmlNode = xmlDoc.SelectSingleNode(xpath);
            XmlAttribute xmlAttribute = null;
            if (xmlNode != null)
            {
                //遍历xpath节点中的所有属性
                foreach (XmlAttribute attribute in xmlNode.Attributes)
                {
                    if (attribute.Name.ToLower() == xmlAttributeName.ToLower())
                    {
                        //节点中存在此属性
                        xmlAttribute = attribute;
                        isExistsAttribute = true;
                        break;
                    }
                }
                if (isExistsAttribute)
                {
                    //删除节点中的属性
                    xmlNode.Attributes.Remove(xmlAttribute);
                }
            }
            xmlDoc.Save(xmlFileName); //保存到XML文档
            isSuccess = true;
        }
        catch (Exception ex)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(typeof(XmlTool));
            log.Error("函数DeleteXmlAttributeByXPath,总参数3,错误信息->" + ex.Message);
            log.Error("函数DeleteXmlAttributeByXPath,参数1,xmlFileName->" + xmlFileName);
            log.Error("函数DeleteXmlAttributeByXPath,参数2,xpath->" + xpath);
            log.Error("函数DeleteXmlAttributeByXPath,参数3,xmlAttributeName->" + xmlAttributeName);
        }
        return isSuccess;
    }

    ///<summary>
    /// 删除匹配XPath表达式的第一个节点中的所有属性
    ///</summary>
    ///<param name="xmlFileName">XML文档完全文件名(包含物理路径)</param>
    ///<param name="xpath">要匹配的XPath表达式(例如:"//节点名//子节点名</param>
    ///<returns>成功返回true,失败返回false</returns>
    public static bool DeleteAllXmlAttributeByXPath(string xmlFileName, string xpath)
    {
        if (string.IsNullOrEmpty(xmlFileName) || string.IsNullOrEmpty(xpath))
        {
            return false;
        }

        bool isSuccess = false;
        XmlDocument xmlDoc = new XmlDocument();
        try
        {
            xmlDoc.Load(xmlFileName); //加载XML文档
            XmlNode xmlNode = xmlDoc.SelectSingleNode(xpath);
            if (xmlNode != null)
            {
                //遍历xpath节点中的所有属性
                xmlNode.Attributes.RemoveAll();
            }
            xmlDoc.Save(xmlFileName); //保存到XML文档
            isSuccess = true;
        }
        catch (Exception ex)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(typeof(XmlTool));
            log.Error("函数DeleteAllXmlAttributeByXPath,总参数2,错误信息->" + ex.Message);
            log.Error("函数DeleteAllXmlAttributeByXPath,参数1,xmlFileName->" + xmlFileName);
            log.Error("函数DeleteAllXmlAttributeByXPath,参数2,xpath->" + xpath);
        }
        return isSuccess;
    }
    #endregion
}

C# 定时器封装

主要是封装System.Threading.Timer控件实现定时任务……

其中Start方法的parallel参数用来限制是否处理并行任务。因为Timer是一个线程任务,如果设置的时间间距小于处理任务所需的时间,那么就会出现任务线程越堆越多最终吃掉整个服务器资源的情况。

房贷计算

最近要买房,纠结于各种计算相当的麻烦,最终,制作了一个房贷计算器,文件如下:计算Excel文件(171116)

**绿色底色的单元格为必填项,其他单元格的值都不要手动修改,均有公式计算。**需要填写贷款金额,贷款年数等信息。值得注意的是,因为贷款过程中利率可能会变动,所以利率那一列是每个月单独一个利率的,需要自己设置。

Python 风格规范

分号

Tip

不要在行尾加分号, 也不要用分号将两条命令放在同一行.

行长度

Tip

每行不超过80个字符

例外

  • 长的导入模块语句
  • 注释里的URL

不要使用反斜杠连接行.

Python会将 圆括号, 中括号和花括号中的行隐式的连接起来 , 你可以利用这个特点. 如果需要, 你可以在表达式外围增加一对额外的圆括号.

Python 语言规范

Lint

Tip

对你的代码运行pylint

定义

pylint是一个在Python源代码中查找bug的工具. 对于C和C++这样的不那么动态的(译者注: 原文是less dynamic)语言, 这些bug通常由编译器来捕获. 由于Python的动态特性, 有些警告可能不对. 不过伪告警应该很少.

Python 解决pip字符集问题

在我的电脑(WIN10)上运行pip命令的时候出现错误提示:

C:\Windows\system32>pip install requests
Collecting requests
Exception:
Traceback (most recent call last):
  File "c:\python27\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "c:\python27\lib\site-packages\pip\commands\install.py", line 324, in run
    requirement_set.prepare_files(finder)
  File "c:\python27\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "c:\python27\lib\site-packages\pip\req\req_set.py", line 620, in _prepare_file
    session=self.session, hashes=hashes)
  File "c:\python27\lib\site-packages\pip\download.py", line 821, in unpack_url
    hashes=hashes
  File "c:\python27\lib\site-packages\pip\download.py", line 659, in unpack_http_url
    hashes)
  File "c:\python27\lib\site-packages\pip\download.py", line 880, in _download_http_url
    file_path = os.path.join(temp_dir, filename)
  File "c:\python27\lib\ntpath.py", line 85, in join
    result_path = result_path + p_path
UnicodeDecodeError: 'ascii' codec can't decode byte 0xcc in position 7: ordinal not in range(128)

提示很明显,就是字符集错误了,Python2的确是有这些字符集问题。

C++ 动态绑定和静态绑定

为了支持c++的多态性,才用了动态绑定和静态绑定。理解他们的区别有助于更好的理解多态性,以及在编程的过程中避免犯错误。

对象的静态类型:对象在声明时采用的类型。是在编译期确定的。

C# 最小二乘法拟合

最小二乘法(又称最小平方法)是一种数学优化技术。它通过最小化误差的平方和寻找数据的最佳函数匹配。

利用最小二乘法可以简便地求得未知的数据,并使得这些求得的数据与实际数据之间误差的平方和为最小。