【发布时间】:2017-08-29 21:39:29
【问题描述】:
我一直坚持在 Linux 路径中使用 python 变量来显示内容,任何建议/指导/提示都会非常有帮助。
下面是我的python脚本:
#!/bin/python
import sys
import os
db = sys.argv[1]
type = sys.argv[2]
if type == "extract":
path= 'extractfolder'
elif type == "transform"
path = 'transformfolder'
到目前为止我很成功,现在我想根据路径变量显示文件。我被困在这里:
os.system('hadoop fs -cat /bla/bla/%s/bla/%s/file.txt ' %db %path)
Error: Traceback (most recent call last): File "./test.py", line 29,in <module>
os.system('hadoop fs -cat /bla/bla/%s/bla/%s/file.txt' %db %path)
TypeError: not enough arguments for format string
研究完成:
我查了os.system也查到了subprocess,但是子进程包不是很好,没有得到任何提示。
【问题讨论】:
标签: python