美文网首页
Python3黑科技之中文编程你值得拥有

Python3黑科技之中文编程你值得拥有

作者: 阿弥陀丸君 | 来源:发表于2018-03-09 16:30 被阅读25次

    笔者使用Python3.6.1版本试验了下中文支持,直接上结果感受下:

    import subprocess
    from Conf.全局配置文件 import 是否启用全局配置
    
    
    class 安卓支持包:
        def 获取截图(self):
            中国 = "中国"
            print(中国)
            s = subprocess.getoutput("adb pull /sdcard/screenshot_auto.png Log/screenshot_auto.png")
            if "no devices" in s:
                return False
            else:
                return True
    print(是否启用全局配置)
    安 = 安卓支持包()
    安.获取截图()
    

    输出结果:

    True
    中国
    

    神不神奇? 强不强大?
    以后再也不用担心团队之间英文命名的难以理解了!

    笔者试着搜了下,原来Python3.0就已经支持unicode定义啦!详情见:Python官网文档unicode定义支持
    还没试用过的小伙伴儿们快试试吧!

    相关文章

      网友评论

          本文标题:Python3黑科技之中文编程你值得拥有

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