![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python学习
学习python过程中总结的一些小知识
Jojo su
冲冲冲,要努力鸭
展开
-
os.path.abspath与os.path.realpath 区别
os.path.realpath 返回的是使用软链的真实地址os.path.abspath 返回目标地址创建a.txt:touch a.txt创建a.txt的软连接:ln -s a.txt b.txt进入python编辑器原创 2022-06-30 10:35:41 · 721 阅读 · 0 评论 -
关于json.dumps()和json.loads()
序列化和反序列化原创 2022-06-10 10:53:26 · 295 阅读 · 0 评论 -
记录xlrd无法读取xlsx的解决方法
xlrd.biffh.XLRDError: Excel xlsx file; not supported解决方法:卸载最新的xlrd,安装老版本的xlrd1、pip uninstall xlrd2、pip install xlrd==1.2.0原创 2022-05-31 10:09:27 · 370 阅读 · 0 评论 -
os.path.join()函数
os.path.join()函数用来拼接文件路径1、如果各参数名首字母不包含/,则函数会自动加上2、从后往前数,从第一个以"/"开头的参数(倒数第一个)开始拼接例:import ospath1 = os.path.join("a", "b", "c")print(path1)path2=os.path.join("/a","/b","c")#从b开始拼接print(path2)输出:a\b\c/b\c需要注意的是:Linux⽤的是/,Windows⽤的是\...原创 2022-05-22 11:41:08 · 182 阅读 · 0 评论 -
os.path.dirname(os.path.realpath(__file__))函数
这个函数其实就是获取文件所在的绝对路径例:test_path.py文件路径是F:\hhh\pytest1\testcases\test_path.py使用os.path.dirname(os.path.realpath(__file__))获得的路径是F:\hhh\pytest1\testcases再套一层os.path.dirname获得的路径是F:\hhh\pytest1,通过这样的方式可以获得项目的根路径...原创 2022-05-22 10:45:14 · 1856 阅读 · 0 评论