【Python】注释

一、Python注释:

1.单行注释
python中单行注释采用 # 开头。

#!/usr/bin/python
# coding:utf-8

import os
import sys
import optparse

def print_name():
    name = os.path.dirname(sys.argv[0])
    print name

#打印输出
print_name()

2.多行注释
python 中多行注释使用三个单引号(''')或三个双引号(""")。

#!/usr/bin/python
# coding:utf-8

import os
import sys
import optparse
'''
def print_name():
    name = os.path.dirname(sys.argv[0])
    print name

#打印输出
print_name()
'''
mycode = 'print("你好")'
exec mycode

猜你喜欢

转载自www.cnblogs.com/wucaiyun1/p/12919531.html