|
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import os
class SingleClass(object):
def __init__(self,x = 0):
self.x = 0
sc = SingleClass()
def tsc():
print(sc.x)
sc.x = 18
print(sc.x)
def tsc20():
print(sc.x)
sc.x = 9
print(sc.x)
if __name__ == '__main__':
sc.tsc()
sc.tsc2()
输出报错:
Traceback (most recent call last):
File "D:/SW/Python/program-defined/59_design_model.py", line 18, in <module>
sc.tsc()
NameError: name 'sc' is not defined
|
|