发现 v 站上有不少萌妹子问 python 问题,每次遇到都忍不住要回答一下,但是 v 站的回复格式实在太闹心了,空格完全消失了。于是想到了一个 ugly 的办法,就是用中文空格替换英文空格,这样代码就不会乱七八糟了(至少看起来)
https://gist.github.com/xuboying/d732d9d4f509b07c8a2041ef6bc7c755
1
xuboying OP 举个例子
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. |
2
oott123 2016-04-18 12:49:04 +08:00
讲道理,还不如在自定义 css 里给帖子内容加个 white-space 属性来得方便快捷……
|
3
learnshare 2016-04-18 12:54:51 +08:00
是全角空格和半角空格吧
|
4
xuboying OP @learnshare 哈哈哈,我完全忘记了半角和全角的术语了
|
6
sciooga 2016-04-21 14:56:12 +08:00 via Android
装上 V2EX plus 呗,早段时间已经添加了类似的功能
|