我有一个功能:
def check_disk_space(path):
import os
"""
check_disk_space() checks the available space of a specified path
"""
cmdparts = ["echo $(df --output=pcent ", ") | tr -d 'Use% '"]
check_disk_space_cmd = cmdparts[0] + path + cmdparts[1]
print type(os.system(check_disk_space_cmd))
return os.system(check_disk_space_cmd)
如果我像这样运行:
if int(check_disk_space('/path/here')) == 12 :
print "wooot"
我得到的不是woot
,而是:
TypeError: int() argument must be a string or a number, not 'NoneType'
如果我打印出os.system(check_disk_space_cmd)
的type()
,我得到'int'
,那么12
的值。你知道吗
你知道这里怎么了吗?我迷路了。你知道吗
谢谢你。你知道吗
函数需要返回值,所以函数的最后一行应该如下所示
相关问题 更多 >
编程相关推荐