I have a script where I want to check if a file exists in a bucket and if it doesn't then create one.
I tried using os.path.exists(file_path)
where file_path = "/gs/testbucket"
, but I got a file not found error.
I know that I can use the files.listdir()
API function to list all the files located at a path and then check if the file I want is one of them. But I was wondering whether there is another way to check whether the file exists.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…