0
A
回答
3
我相信這將是非常簡單的,你
os.path.abspath(os.path.pardir)
或者也可以簡單
os.path.dirname(os.getcwd())
1
我不知道,做它的方法,但我會做這樣的事情:
os.path.abspath(os.path.join(os.getcwd(), os.pardir))
編輯:這樣的作品,但Ixanezis方式可能會更好。
1
那麼,這種方法可能是有用的:
os.path.dirname(os.getcwd())
相關問題
- 1. Python的等價物@
- 2. TSQL/MySQL等價物
- 3. Ext JS等價物
- 4. VB.NET HashMap等價物
- 5. BufferedImage.getRGB C#等價物?
- 6. Python等價物repr()?
- 7. Ruby的cURL的等價物?
- 8. PostgreSQL的mysql_insert_id()的等價物?
- 9. Phoenix的Rails.env.production的等價物?
- 10. CCLayer的-viewDidAppear的等價物?
- 11. BeanShell的等價物淨
- 12. AS2中Event.MOUSE_LEAVE的等價物
- 13. NSTask或iPhone的等價物
- 14. 蟒蛇的Maven等價物
- 15. Python的等價物__setitem__
- 16. Cocoa中UIScrollViewDelegate的等價物?
- 17. mstest中assert.warning的等價物?
- 18. R:MCMCpack :: MCMClogit的predict.glm等價物
- 19. tcl中#define的等價物?
- 20. Mathematica中的Sprintf等價物?
- 21. PHP的等價物str_word_count?
- 22. Python的等價物find2perl
- 23. LibreOffice的RTD等價物
- 24. PHP的mysql等價物mysql_real_escape_string()
- 25. WPF中BeginUpdate的等價物?
- 26. Java的Ruby等價物ObjectSpace.each_object
- 27. Java的Drupal等價物?
- 28. 「this」指針的等價物
- 29. Mac/iPhone的objcopy等價物?
- 30. Encoding.Unicode.GetByteCount(str)的C++等價物?
[獲取父母的可能重複目錄在Python中](http://stackoverflow.com/questions/2860153/get-parent-directory-in-python) – 2012-04-09 19:46:19
Plea我不認爲'os.set =='/''就是這樣。在'os.path'中有現成的函數:'split','join','basename'等。 – delnan 2012-04-09 19:50:45