如何使用python删除隐藏文件夹中的文件?

时间:2018-12-17 14:31:48

标签: python

我想删除一个文件,例如。存储在隐藏文件夹下的“ myfile.txt”。可以在python中做到吗?

谢谢

1 个答案:

答案 0 :(得分:1)

是的,只需将路径包括以下隐藏文件夹即可:

UNIX:

string connectionStr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\WordssTable.mdb;
Persist Security Info=False";
using(OleDbConnection connectObj = new OleDbConnection(connectionStr))
using(OleDbCommand command = new OleDbCommand())
{
    connectObj.Open();
    command.Connection = connectObj;
    command.CommandText = "SELECT * FROM WordsTable WHERE EnglishWord=@text";
    command.Parameters.Add("@text", OleDbType.VarWChar).Value = hebw1.Text;
    using(OleDbDataReader reader = command.ExecuteReader())
    {
        // Try to read the first record, if any, and then update the labels
        if(reader.Read())
        {
             hebw1.Text = reader["hebw1"].ToString();
             hebw2.Text = reader["hebw2"].ToString();
             hebw3.Text = reader["hebw3"].ToString();
             hebw4.Text = reader["hebw4"].ToString();
        }
   }
}

WINDOWS(来自here的代码):

path = "desktop/.hidden_folder/myfile.txt"

然后根据需要处理文件。