- 安装python3
mkdir -p /usr/local/openssl/
cd /software/ && tar -zxvf openssl-1.1.1m.tar.gz
cd /software/openssl-1.1.1m/ && ./config --prefix=/usr/local/openssl
make -j20
make install
mv /usr/bin/openssl /usr/bin/openssl.old
mv /usr/lib64/openssl /usr/lib64/openssl.old
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
ldconfig -v
cd /software/python3 && tar xvf Python-3.10.5.tgz && cd Python-3.10.5 && ./configure --prefix=/software/python3/Python-v3.10.5 --with-openssl=/usr/local/openssl && make -j20 && make install
-
sys.path[0]为python脚本所的位置os.getcwd()为当前工作目录
-
指定镜像快速安装python模块示例:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple numpy
cmd=os.popen('whoami')
user=cmd.read()
user=user.strip()
- 字符匹配
datepat = re.compile(r'(\d+)/(\d+)/(\d+)’)
m = datepat.match('11/27/2012’)
>>> m.group(0)
'11/27/2012'
>>> m.group(1)
'11'
>>> m.group(2)
'27'
>>> m.group(3)
‘2012'
- 获得当前时间
t=time.asctime()
print(t)
- 随机产生字符串作为文件名
unique_filename = str(uuid.uuid4())
- 数组去重并排序
set1=sorted(list(set(array)),reverse=True)
- 判断文件大小
size=os.path.getsize()
- enumerate枚举
a = ['a', 'b', 'c', 'd', 'e']
>>> for index, item in enumerate(a): print index, item