Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 将子进程out out转换为整数_Python 2.7 - Fatal编程技术网

Python 2.7 将子进程out out转换为整数

Python 2.7 将子进程out out转换为整数,python-2.7,Python 2.7,我在python中面临一些挑战,我需要一些帮助。 我正在尝试将SubAccess输出转换为整数。 我有几本以年为单位的目录。例如,运行命令ls-l/directory,将返回 2015年 2016 2018年 当我检查输出类型时,它显示数据是字符串格式的。 我应该可以把它转换成一个整数 但是,当我尝试以下代码时: child = subprocess.Popen("ls -l /directory | awk '{print $9}'", stdin=subprocess.PIPE, stder

我在python中面临一些挑战,我需要一些帮助。 我正在尝试将SubAccess输出转换为整数。 我有几本以年为单位的目录。例如,运行命令ls-l/directory,将返回

2015年 2016 2018年

当我检查输出类型时,它显示数据是字符串格式的。 我应该可以把它转换成一个整数

但是,当我尝试以下代码时:

child = subprocess.Popen("ls -l /directory | awk '{print $9}'", stdin=subprocess.PIPE, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, shell=True) 

output = child.communicate()[0]

for line in output.split("\n"):
 print int(line)
我收到以下错误“ValueError:以10为基数的int()的文本无效:“”

请帮忙