0
Gtk2에서 파일 선택을 사용하고 있습니다. 파이썬에서 Bash Command (stat "some directory")를 사용하고 싶습니다. 이 코드에서 파일 디렉토리는 "텍스트"변수에 저장됩니다. 하지만 작동하지 않습니다. python으로 작성된 stat() 메소드는 사용하고 싶지 않습니다. gtk에서 bash 명령
Gtk2에서 파일 선택을 사용하고 있습니다. 파이썬에서 Bash Command (stat "some directory")를 사용하고 싶습니다. 이 코드에서 파일 디렉토리는 "텍스트"변수에 저장됩니다. 하지만 작동하지 않습니다. python으로 작성된 stat() 메소드는 사용하고 싶지 않습니다. gtk에서 bash 명령
os.system('stat' + ' '.join(os.listdir(text)))
#!/usr/bin/python
import pygtk
import gtk
import os
class fileselection:
def file_ok_sel(self,w):
print("%s " % self.filew.get_filename())
text=self.filew.get_filename()
print(text)
os.system("stat os.listdir("text")")
#print(os.stat(text))
#os.system("stat os.dir(text)")
def destroy(self,widget):
gtk.main_quit()
def __init__(self):
self.filew=gtk.FileSelection("File selection")
self.filew.connect("destroy",self.destroy)
self.filew.ok_button.connect("clicked",self.file_ok_sel)
self.filew.cancel_button.connect("clicked",lambda w:self.filew.destroy())
self.filew.set_filename("penguin.png")
self.filew.show()
def main():
gtk.main()
return 0
if __name__=="__main__":
fileselection()
main()
subprocess
모듈을 사용하는 것이 좋습니다 :
https://docs.python.org/2/library/subprocess.html#module-subprocess
을 당신은'+'가 아닌 병렬로 사용하여 문자열을 연결해야합니다' "합계 os.listdir을 ("text") "'는 작동하지 않습니다; ' "stat os.listdir ("+ text + ")"'가 작동합니다. – Rufflewind