zoukankan      html  css  js  c++  java
  • Python

    背景

    写 python 的时候,基本都要加两个头部注释,这到底有啥用呢?

    #!usr/bin/env python
    # -*- coding:utf-8 _*-
    
    print("hello-world")

    python 头部注释的作用

    • 头注释并不是为代码而服务,更多是被系统或解释器所调用
    • 会告诉系统 Python 解释器在哪,脚本编码格式是啥

    常用的头部注释

    国内常用

    定义 coding 告诉系统脚本是何种编码格式

    # -*- coding:utf-8 _*-

    很少用了

    定义 #!,会去找指定路径下的 python 解释器

    #!usr/bin/env python
  • 相关阅读:
    20210420
    20210419
    2021041601
    20210416
    20210415
    20210414
    20210413
    20210412
    20210409
    20210405
  • 原文地址:https://www.cnblogs.com/poloyy/p/15027296.html
Copyright © 2011-2022 走看看