在我的GlobalObject.py Python文件中,我定义了一个名为ProjectVarible的类:
import os
import pandas as pd
class ProjectVarible:
def __init__(self):
self.cwd = os.getcwd()
self.InPath = self.cwd + '\\data\\'
self.OutPath = self.cwd + '\\result\\'
self.ipoPreQuarter = 11
self.screenDataPre = 19
self.assetPoolName = 'AllAStock'
self.indicator = 'amt'
def show(self):
print('current set:')
print('pastDataLen = ', self.pastDataLen, end=';\t')
print('recentDataLen = ', self.recentDataLen, end=';\t')
print('assetPoolName = ', self.assetPoolName, end=';\t')
print('indicator = ', self.indicator)
def which(series,value):
DF=pd.DataFrame({'index':range(len(series)),'value':series})
resultdf=DF.loc[DF['value']==value,:]
return list(resultdf['index'])
当我创建名为PVariable的ProjectVarible对象时,InPath属性运行良好:
from GlobalObject import *
PVariable=ProjectVarible()
path=PVariable.InPath
path
Out[143]: 'D:\\PycharmProjects\\Entropy Capital\\Financial Indicator\\Fundamental.2\\data\\'
但是当我调用ipoPreQuarter属性时,它不起作用并返回一个AttributeError:
ipoPreQ=PVariable.ipoPreQuarter
Traceback (most recent call last):
File "D:\ProgramData\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2862, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-144-abaa7a33b94f>", line 1, in <module>
ipoPreQ=PVariable.ipoPreQuarter
AttributeError: 'ProjectVarible' object has no attribute 'ipoPreQuarter'
出了什么问题?,我该如何使用这些属性?