爱意满满的作品展示区。
xuboying

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

  •  
  •   xuboying · Apr 18, 2016 · 2651 views
    This topic created in 3858 days ago, the information mentioned may be changed or developed.

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

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

    6 replies  •  2016-04-21 14:56:12 +08:00
    xuboying
    xuboying
    OP
    Apr 18, 2016
    1
    举个例子

    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
    oott123
    Apr 18, 2016
    2
    讲道理,还不如在自定义 css 里给帖子内容加个 white-space 属性来得方便快捷……
    learnshare
    learnshare
    Apr 18, 2016
    3
    是全角空格和半角空格吧
    xuboying
    xuboying
    OP
    Apr 18, 2016
    4
    @learnshare 哈哈哈,我完全忘记了半角和全角的术语了
    xuboying
    xuboying
    OP
    Apr 18, 2016
    5
    @oott123 能者多劳,做一个发布到 stylish 里呗,方便大家
    sciooga
    sciooga
    Apr 21, 2016 via Android
    6
    装上 V2EX plus 呗,早段时间已经添加了类似的功能
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4526 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 01:21 · PVG 09:21 · LAX 17:21 · JFK 20:21
    ♥ Do have faith in what you're doing.