一、python单行注释符号(#)
python中单行注释采用 #开头
示例:
#this is a comment
二、批量、多行注释符号
多行注释是用三引号,例如:
输入''' '''或者""" """,将要注释的代码插在中间
相关推荐:《python视频教程》
三、windows下的idle的注释快捷键是alt+3,取消注释是alt+4
四、python中文注释方法
今天写脚本的时候,运行报错:
syntaxerror: non-ascii character '\xe4' in file getopttest.py on line 14, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
如果文件里有非ascii字符,需要在第一行或第二行指定编码声明。把chinesetest.py文件的编码重新改为ansi,并加上编码声明:
一定要在第一行或者第二行加上这么一句话:
#coding=utf-8
或者
# -*- coding: utf-8 -*-
以上就是python的注释有哪几种的详细内容。
