Python os.getcwdu () -Methode
Python OS Datei / Verzeichnis - Methoden
Umriss
os.getcwdu () Methode gibt ein Unicode aktuellen Arbeitsverzeichnis Objekte.
Unix, Windows-System zur Verfügung.
Grammatik
getcwdu () -Methode Syntax lautet wie folgt:
os.getcwdu()
Parameter
- keine
Rückgabewert
Gibt ein Unicode aktuelle Arbeitsverzeichnis Objekte.
Beispiele
Das folgende Beispiel zeigt getcwdu () Art der Nutzung:
#!/usr/bin/python # -*- coding: UTF-8 -*- import os, sys # 切换到 "/var/www/html" 目录 os.chdir("/var/www/html" ) # 打印当前目录 print "当前工作目录 : %s" % os.getcwdu() # 打开 "/tmp" fd = os.open( "/tmp", os.O_RDONLY ) # 使用 os.fchdir() 方法修改目录 os.fchdir(fd) # 打印当前目录 print "当前工作目录 : %s" % os.getcwdu() # 关闭文件 os.close( fd )
Das obige Programm Ausgabe lautet:
当前工作目录 : /var/www/html 当前工作目录 : /tmp