1.pip安装豆瓣源例子
#只要正常pip install ***,install后面添加 -i https://pypi.douban.com/simple 就行,这样用了国内库源加快下载安装速度
2.os(join abspath dirname)文件地址读取与拼接
1)dirname 读取当前文件的文件夹名称 os.path.dirname(file) __file__当前文件,
2) abspath 获取当前文件的绝对路径
3)join 关联起来,路径与文件相连接、
4)listdir 展示出当前目录下所有文件
5)getcwd 展示当前目录路径
import os
c=os.path.dirname(__file__)
a=os.path.abspath(c)
b=os.path.join(a,"aa")
print(a)
print(b)
print(c)
3.endswith startswith使用
aa=["qaa","cc","sss"]
print([bb for bb in aa if not bb.endswith("c")])
print([bb for bb in aa if not bb.startswith("q")])
-------------------------------------------------------结果---------------------
['qaa', 'sss']
['cc', 'sss']