V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
xuboying
V2EX  ›  分享创造

英文空格转中文空格的 javascript bookmark 脚本

  •  
  •   xuboying · 2016-04-18 12:31:58 +08:00 · 1902 次点击
    这是一个创建于 2938 天前的主题,其中的信息可能已经有所发展或是发生改变。

    发现 v 站上有不少萌妹子问 python 问题,每次遇到都忍不住要回答一下,但是 v 站的回复格式实在太闹心了,空格完全消失了。于是想到了一个 ugly 的办法,就是用中文空格替换英文空格,这样代码就不会乱七八糟了(至少看起来)

    https://gist.github.com/xuboying/d732d9d4f509b07c8a2041ef6bc7c755

    6 条回复    2016-04-21 14:56:12 +08:00
    xuboying
        1
    xuboying  
    OP
       2016-04-18 12:32:25 +08:00
    举个例子

    prices = {'apple': 0.40, 'banana': 0.50}
    my_purchase = {
      'apple': 1,
      'banana': 6}
    grocery_bill = sum(prices[fruit] * my_purchase[fruit]
              for fruit in my_purchase)
    print 'I owe the grocer $%.2f' % grocery_bill

    ### Warning: Above code may contain Chinese wide whitespace for human friendly reading in web browser.
    ### Do: replace them back to double space in your favorite text editor to satisfy you compiler/interpreted.
    oott123
        2
    oott123  
       2016-04-18 12:49:04 +08:00
    讲道理,还不如在自定义 css 里给帖子内容加个 white-space 属性来得方便快捷……
    learnshare
        3
    learnshare  
       2016-04-18 12:54:51 +08:00
    是全角空格和半角空格吧
    xuboying
        4
    xuboying  
    OP
       2016-04-18 12:59:48 +08:00
    @learnshare 哈哈哈,我完全忘记了半角和全角的术语了
    xuboying
        5
    xuboying  
    OP
       2016-04-18 13:00:50 +08:00
    @oott123 能者多劳,做一个发布到 stylish 里呗,方便大家
    sciooga
        6
    sciooga  
       2016-04-21 14:56:12 +08:00 via Android
    装上 V2EX plus 呗,早段时间已经添加了类似的功能
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2433 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 08:50 · PVG 16:50 · LAX 01:50 · JFK 04:50
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.