通过使用glob排除某些目录来列出文件名

时间:2017-06-17 07:44:50

标签: python python-2.7 glob

我的目录结构如下:

   //I want to call the variables of the Variables() method to this one..but how?? 
    public void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { 


         float flin = Third.variables(fin);
          JOptionPane.showMessageDialog(null,"Your Percentage for this Cycle Test is: "+flin+"%");
          this.dispose();
          Fourth  IV = new Fourth();
          IV.setVisible(true);



         }

我想在单个语句中列出root/person1/yes/ root/person1/no/type1/ root/person1/no/type2/ root/person1/no/type3/ root/person1/no/type4/ root/person2/yes/ root/person2/no/type1/ root/person2/no/type2/ root/person2/no/type3/ root/person2/no/type4/ root/person3/yes/ root/person3/no/type1/ root/person3/no/type2/ root/person3/no/type3/ root/person3/no/type4/ root/*/no/type1中所有带有python root/*/no/type2函数的.txt文件,如:

glob.glob

lst = glob.glob('root/*/no/(type1||type3)/*.txt')

1 个答案:

答案 0 :(得分:-2)

Glob patterns没有“或”,但在这种情况下您可以使用字符匹配:

lst = glob.glob('root/*/no/type[12]/*.txt')