zoukankan      html  css  js  c++  java
  • python 去掉 多余空格

    >>> import re

    >>> 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)"

    >>> pattern = re.compile('[ ]+')

    >>> 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)"

  • 相关阅读:
    泛型
    HTTP和HTTPS
    计算机网络(三)应用层
    练习38-操作列表
    第27讲:集合—在我的世界里,你就是唯一
    第25~26讲:字典:当索引不好用时
    第1~2讲:数据结构和算法绪论
    第23~24讲:这帮小兔崽子(斐波那契数列)和汉诺塔游戏
    练习36--设计和调试
    001-定义电子日历类
  • 原文地址:https://www.cnblogs.com/yuyue2014/p/4567813.html
Copyright © 2011-2022 走看看