杂七杂八整理

  1. 如何hexo+next添加algolia搜索

    参考文章地址

  2. jupyter需要加载安装好的虚拟环境

  3. python编码规范

    ​ 等号一般在赋值的时候两边都要加空格,但是当’=’用于指示关键字参数或默认参数值时, 不要在其两侧使用空格.

    1. 1
      Yes: def complex(real, imag=0.0): return magic(r=real, i=imag)

      避免在循环中用+和+=操作符来累加字符串. 由于字符串是不可变的, 这样做会创建不必要的临时对象, 并且导致二次方而不是线性的运行时间. 作为替代方案, 你可以将每个子串加入列表, 然后在循环结束后用 .join 连接列表. (也可以将每个子串写入一个 cStringIO.StringIO 缓存中.)

      1
      2
      3
      4
      5
      6
      7
      8
      9
      Yes: x = a + b
      x = '%s, %s!' % (imperative, expletive)
      x = '{}, {}!'.format(imperative, expletive)
      x = 'name: %s; score: %d' % (name, n)
      x = 'name: {}; score: {}'.format(name, n)
      No: x = '%s%s' % (a, b) # use + in this case
      x = '{}{}'.format(a, b) # use + in this case
      x = imperative + ', ' + expletive + '!'
      x = 'name: ' + name + '; score: ' + str(n)
  4. 英语积累

    1. Tensor and Function are interconnected and build up an acyclic graph