Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda : 4.5.11    typesetting : Markdown   code coder@Ubuntu:~$ source activate py37 (py37) coder@Ubuntu:~$ ipython Python 3.6.5 |Anaconda, Inc.| (default,…
         Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda : 4.5.11    typesetting : Markdown   code coder@Ubuntu:~$ source activate py37 (py37) coder@Ubuntu:~$ ipython Python 3.6.5 |Anaconda, Inc.| (default,…
         Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda : 4.5.11    typesetting : Markdown   code coder@Ubuntu:~$ source activate py37 (py37) coder@Ubuntu:~$ ipython Python 3.6.5 |Anaconda, Inc.| (default,…
python获取文件上一级目录:取文件所在目录的上一级目录 os.path.abspath(os.path.join(os.path.dirname('settings.py'),os.path.pardir)) os.path.pardir是父目录,os.path.abspath是绝对路径 举例具体看一下输出: print os.path.dirname(os.path.abspath("__file__"))     print os.path.pardir     print o…
import os str1 = "grsdgfd" str2 = "wddf" str3 = "gddgs" # print(str1 + str2 + str3) ret = os.path.join(str1,str2,str3) print(ret)结果:grsdgfd\wddf\gddgs os.path.dirname返回上一级目录相当于os.path.split(path) import os str1 = "grsdgf…
         Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda : 4.5.11    typesetting : Markdown   code coder@Ubuntu:~$ source activate py37 (py37) coder@Ubuntu:~$ ipython Python 3.6.5 |Anaconda, Inc.| (default,…
import os print '***获取当前目录***' print os.getcwd() print os.path.abspath(os.path.dirname(__file__)) print '***获取上级目录***' print os.path.abspath(os.path.dirname(os.path.dirname(__file__))) print os.path.abspath(os.path.dirname(os.getcwd())) print os.path…
         Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda : 4.5.11    typesetting : Markdown   code coder@Ubuntu:~$ source activate py37 (py37) coder@Ubuntu:~$ ipython Python 3.6.5 |Anaconda, Inc.| (default,…
         Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda : 4.5.11    typesetting : Markdown   txt(utf-8) <道德经>原文 "我有三宝持而保之∶一曰慈,二曰俭,三曰不敢为天下先."   code """ @Author : 行初心 @Date : 18-10-…
         Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda : 4.5.11    typesetting : Markdown   example_1 code coder@Ubuntu:~$ source activate py37 (py37) coder@Ubuntu:~$ ipython Python 3.6.5 |Anaconda, Inc.|…