美文网首页Python
Python基本命令

Python基本命令

作者: anyurchao | 来源:发表于2018-07-09 15:18 被阅读1次
    一.命令行运行文件
    python hello.py                    
    
    二.直接运行py文件
    1.文件中增加如下
    #!/usr/bin/env python
    2.命令行
    chmod a+x hello.py
    3.命令行
    ./文件名
    
    三.ASCII编码互转
    >>> ord('A')
    65
    >>> chr(65)
    'A'
    
    Unicode编码互转
    >>> print u'中文'
    中文
    >>> u'中'
    u'\u4e2d'
    
     u'中文'.encode('utf-8')
    
    四.len()函数可以返回字符串的长度
    >>> len(u'ABC')
    3
    >>> len('ABC')
    3
    >>> len(u'中文')
    2
    >>> len('\xe4\xb8\xad\xe6\x96\x87')
    6
    

    详细文件移步Python学习笔记

    相关文章

      网友评论

        本文标题:Python基本命令

        本文链接:https://www.haomeiwen.com/subject/lvqtpftx.html