2021年3月2日星期二

How would I return list that looks like this [1,2,3,4] instead of returning something like ['1','2','3','4']?

whenever I run this code it leaves a list that is like ['1999','2000',] and therefore I cannot perform an operation like ' m, b = np.polyfit(x, y, 1)'

  def getCH4():      years = []      ch4 = []        try:          sqlConnect = sqlite3.connect('table1.db')          cursor = sqlConnect.cursor()          print("connected for reading")            sqlite_SelectQuery = """SELECT * from datahub"""          cursor.execute(sqlite_SelectQuery)          records = cursor.fetchall()            for row in records:              years.append(row[0])              ch4.append(row[2])                cursor.close()        except sqlite3.Error as error:          print("Failed to read data from sqlite table", error)        finally:          if (sqlConnect):              sqlConnect.close()              print("The SQLite connection is closed")      time.sleep(1)      return years, ch4    
https://stackoverflow.com/questions/66450647/how-would-i-return-list-that-looks-like-this-1-2-3-4-instead-of-returning-some March 03, 2021 at 12:07PM

没有评论:

发表评论