代码一
#! /usr/bin/env python
"""
@Time : 2018/8/22 14:22
@Author : Damao
@Site : Life is short. I use python.
@File : test1.py
@Software : PyCharm
"""
def foo():
b = 'hello'
def bar(): # Python中可以在函数内部再定义函数
c = True
print(a)
print(b)
print(c)
bar()
# print(c) # NameError: name 'c' is not defined
if __name__ == '__main__':
a = 100
# print(b) # NameError: name 'b' is not defined
foo()
代码二
#! /usr/bin/env python
"""
@Time : 2018/8/22 14:23
@Author : Damao
@Site : Life is short. I use python.
@File : test2.py
@Software : PyCharm
"""
"""函数代码的编写方式"""
def main():
# Todo: Add your code here
pass
if __name__ == '__main__':
main()
网友评论