我有一个文件file1.py,它具有类和一个方法,我想在file2.py中导入方法的变量之一。
file1.py
class Consumer(threading.Thread):
daemon = True
def __init__(self, kafka_consumer, user_id):
self._consumer = kafka_consumer
self._user_id=user_id
def processPriceUpdateMsg(self,msg):
usersFullPositionData=globaldata.GlobalDataAdapter.GetFullPositionData(self._user_id)
payloadStr=msg["payload"]
payload=json.loads(payloadStr)
bloombergIdentifier=payload['subscriptionId'].split("?")[0].split("/")[-1].strip()
marketDataEvent=payload['MarketDataEvents']
lastPrice=marketDataEvent['LAST_PRICE']
priceupdateDF = usersFullPositionData.loc[usersFullPositionData['BloombergIdentifier'].isin([bloombergIdentifier])][['Price']]
file2.py
from file1 import Consumer
consumer1 = Consumer('<kafka.consumer.group.KafkaConsumer object at 0x0AD83F90>', 'User1', '10.10.60.212:9092','user1-positions')
def get_priceupdate_new_df():
consumer1.processPriceUpdateMsg(msg).lastPrice
我想将lastPrice从file1(processPriceUpdateMsg)导入到file2。我该怎么办?