这是我的代码:
import win32api
import wmi
def username_func():
uname = win32api.GetUserName()
print "Username is:" ,uname, "\r "
def disk_func():
c = wmi.WMI()
for disk in c.Win32_LogicalDisk (DriveType=3):
print disk.Caption, "%0.1f%% vrij \r" % (100.0 * long (disk.FreeSpace) / long (disk.Size)),long (disk.FreeSpace) / long (1073741824),"gb van",long (disk.Size) / long (1073741824),"gb"
print
def main():
username_func()
disk_func()
main()
raw_input("Press Enter to continue...")
当我运行这是 pyscripter 时,它给了我这个输出:
Username is: ******
C: 66.7% vrij
79 gb van 119 gb
D: 21.9% vrij
130 gb van 596 gb
当我双击 python.py 时,我得到不同的输出:
sername is: *****
79 gb van 119 gb
130 gb van 596 gb
为什么是这样?我忘记了什么吗?