closes = [] def check_indicator(): global closes closes.reverse() print(closes) connection = psycopg2.connect( host='localhost', database='postgres', user='postgres', password='pass' ) connection.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT) cur = connection.cursor() cur.execute('select closeprice from candles order by datetime desc limit 54') closes.extend(cur.fetchall()) check_indicator()
When running the code above I get an unreversed list of closes
what causes that to occur? I have already declared global closes
inside the function. However, when I declare a variable that depends on closes
inside the function like this one reversed_closes = closes.reverse()
this returns with None
没有评论:
发表评论