class Test:
def __init__(self, path):
Test.data = os.path.join(path, 'data')
def Function:
A = Test('/home/gg/a/')
B = Test('/home/gg/b/')
C = Test('/home/gg/c/')
print A.data
print B.data
print C.data
這樣寫的話執行Function結果如下
/home/gg/c/data
/home/gg/c/data
/home/gg/c/data
想了一下子才發現應該要這樣寫才對
class Test: def __init__(self, path):
self
.data = os.path.join(path, 'data')
這樣才會正確的印出
/home/gg/a/data
/home/gg/b/data
/home/gg/c/data
超不專業的我Orz
沒有留言:
張貼留言