>>> import re
>>> sss = "SELECT a.id,\n a.customer_id as user_id,\n c.image au_icon,\n c.nick_name au_name,\n a.title,\n a.content,\n a.cover_image image_url,\n UNIX_TIMESTAMP(ifnull(a.last_update, a.ctime)) last_update,\n a.goods * 3+ a.goods_init ups,\n a.views * 3+ a.views_init play_count,\n a.reviews comment_count,\n IF(a.is_essence, ‘true‘, ‘false‘) is_essence,\n a.type,\n a.game_id,\n g.title game_name,\n UNIX_TIMESTAMP(a.ctime) create_time,\n a.images\n FROM articles a LEFT JOIN games g ON g.is_del= 0\n AND g.id= a.game_id left join customers c on a.customer_id= c.id\n where a.is_del= 0\n and a.status= 1\n AND a.type= ‘video‘\n AND a.game_id!= 223\n and a.id IN(1)"
>>> pattern = re.compile(‘[\t\n ]+‘)
>>> re.sub(pattern, ‘ ‘, sss)
"SELECT a.id, a.customer_id as user_id, c.image au_icon, c.nick_name au_name, a.title, a.content, a.cover_image image_url, UNIX_TIMESTAMP(ifnull(a.last_update, a.ctime)) last_update, a.goods * 3+ a.goods_init ups, a.views * 3+ a.views_init play_count, a.reviews comment_count, IF(a.is_essence, ‘true‘, ‘false‘) is_essence, a.type, a.game_id, g.title game_name, UNIX_TIMESTAMP(a.ctime) create_time, a.images FROM articles a LEFT JOIN games g ON g.is_del= 0 AND g.id= a.game_id left join customers c on a.customer_id= c.id where a.is_del= 0 and a.status= 1 AND a.type= ‘video‘ AND a.game_id!= 223 and a.id IN(1)"