Good Day everybody! Is there away to solve this problem ValueError: invalid literal for int() with base 10: '\r' im getting this problem after reading the data from mysql database, i have seen related post same problem , but its not working the solution with me such like here and here and here the data can be read successfully from database but the program stop into this line in the code indices = list(int(x) for x in data[-2:]) : the code working fine when i set the value direct but the problem happen when i read data from database. suppose this data is store in database:
data=3669173122946610524661732905264584239464321015293887264584378370174699627442417573669172466172466172938871746993783703210153210152394642394641864073669176459629027117604963001838526185423176139908966
data=str(data)
def split(data):
indices = list(int(x) for x in data[-2:])
data = data[:-2]
rv = []
for i in indices[::-1]:
rv.append(data[-i:])
data=data[:-i]
rv.append(data)
return rv[::-1]
d1, d2, d3 = split(data)
i'm adding the reading data from database
import mysql.connector
from mysql.connector import Error
try:
mySQLconnection1 = mysql.connector.connect(host='localhost',
database='vcn',
user='vcn',
password='vcn')
sql_select_Query = "select * from pid where id =56"
cursor = mySQLconnection1 .cursor()
cursor.execute(sql_select_Query)
records = cursor.fetchall()
for row in records:
data= row[1]
print(data)
cursor.close()
except Error as e :
print ("Error while connecting to MySQL", e)
finally:
#closing database connection.
if(mySQLconnection1 .is_connected()):
mySQLconnection1.close()
print("MySQL connection is closed")
any suggestion!! thanks all