use strip() to remove leading and trailing whitespace including \n, spaces and single quote '.
x = "int_32\n' " new_x = x.strip("\n' ") print(new_x)