shell与python
1. pip3 安装
linux中:
pip3 list ------- 显示安装的所有第三方库和版本
pip3 intsall 第三方库名称 -i Python国内镜像源地址 ------- 安装第三方库
pip3 install 第三方库名称 -------- 安装第三方库(会很慢)
pip3 install 第三方库名称==版本号 -i 国内镜像源 ----- 安装指定版本的第三方库
pip3 uninstall 第三方库名称 -------- 卸载指定的第三方库
Python国内镜像源
华为镜像源 https://mirrors.huaweicloud.com/
阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
浙江大学开源镜像站 http://mirrors.zju.edu.cn/
腾讯开源镜像站 http://mirrors.cloud.tencent.com/pypi/simple
豆瓣 http://pypi.douban.com/simple/
网易开源镜像站 http://mirrors.163.com/
搜狐开源镜像 http://mirrors.sohu.com/
开头不是https的需要加上s
想要用在脚本中写python代码并运行,但由于shell中写python较为繁琐,或shell中取不到想要的excel中的信息
(需要先安装openpyxl第三方库)
可以选择
先在pycharm 写出python代码,保存并拖进linux中
import openpyxl
wb = openpyxl.load_workbook('files/example1.xlsx')
sheet1 = wb.active
m_r=sheet1.max_row
result = ''
for i in range(2,m_r):
value = sheet1.cell(i,1).value
result += value
if i != m_r:
result += ' '
print(result)
将所要用到的excel文件也拖进linux中
拖进linux的python代码需要改一下excel文件的路径(改为linux中该文件的绝对路径)
创建一个shell文件编写获取python文件并运行
1 a=`python3 /root/py/demo.py`
2 for i in ${a}
3 do
4 echo ${i}
5 done