美文网首页
python 工具文档集锦

python 工具文档集锦

作者: lekf123 | 来源:发表于2018-06-17 15:30 被阅读0次

正常工作时间会搜到各种用到的文档 【持续更新 ... 】。

做记录,标签,个别也会整理下(文档搬运工,尽量给链接不侵权 [^_^]):

Jupyter Notebook 添加目录插件

具体参考如下:

  1. 参考:https://www.jianshu.com/p/7687c6bec65e
  2. 参考:https://www.jianshu.com/p/f314e9868cae
  3. 参考:https://blog.csdn.net/data2word/article/details/79903493

本人直接

conda install -c conda-forge jupyter_contrib_nbextensions

一次性成功。


Python格式化字符串

  1. 参考:https://www.cnblogs.com/wilber2013/p/4641616.html

python 中列表(list)合并、数组(array)合并

参考原文:https://blog.csdn.net/daoxiaxingcai46/article/details/78269910

列表合并

>>> a = [[1,2,3],[4,5,6]]
>>> b = [[1,1,1],[2,2,2]]
>>> c = a+b
>>> c
[[1, 2, 3], [4, 5, 6], [1, 1, 1], [2, 2, 2]]
>>> a.extend(b)
>>> a
[[1, 2, 3], [4, 5, 6], [1, 1, 1], [2, 2, 2]]

数组合并

>>> import numpy as np
>>> a = np.array([[1,2,3],[4,5,6]])
>>> b = np.array([[1,1,1],[2,2,2]])

数组纵向合并:
方法(1)

>>> c = np.vstack((a,b))
>>> c
array([[1, 2, 3],
       [4, 5, 6],
       [1, 1, 1],
       [2, 2, 2]])

方法(2)

>>> c = np.r_[a,b]
>>> c
array([[1, 2, 3],
       [4, 5, 6],
       [1, 1, 1],
       [2, 2, 2]])

数组横向合并:
方法(1)

>>> d = np.hstack((a,b))
>>> d
array([[1, 2, 3, 1, 1, 1],
       [4, 5, 6, 2, 2, 2]])

方法(2)

>>> d = np.c_[a,b]
>>> d
array([[1, 2, 3, 1, 1, 1],
       [4, 5, 6, 2, 2, 2]])

python中的字符数字之间的转换函数

  • int(x [,base ]) 将x转换为一个整数
  • long(x [,base ]) 将x转换为一个长整数
  • float(x ) 将x转换到一个浮点数
  • complex(real [,imag ]) 创建一个复数
  • str(x ) 将对象 x 转换为字符串
  • repr(x ) 将对象 x 转换为表达式字符串
  • eval(str ) 用来计算在字符串中的有效Python表达式,并返回一个对象
  • tuple(s ) 将序列 s 转换为一个元组
  • list(s ) 将序列 s 转换为一个列表
  • chr(x ) 将一个整数转换为一个字符
  • unichr(x ) 将一个整数转换为Unicode字符
  • ord(x ) 将一个字符转换为它的整数值
  • hex(x ) 将一个整数转换为一个十六进制字符串
  • oct(x ) 将一个整数转换为一个八进制字符串
chr(65)='A'
ord('A')=65
int('2')=2;
str(2)='2'

相关文章

网友评论

      本文标题:python 工具文档集锦

      本文链接:https://www.haomeiwen.com/subject/chyweftx.html