问题 When I am analyzing data, I save my dataframes into a csv-file and use pd.to_csv() for that. However, the function (over)writes the new file, without checking whether there exists one with the same name. Is there a way to check whether the file already exists, and if so, ask for a new filename? I know I can add the system's datetime to the filename, which will prevent any overwriting, but I would like to know when I made the mistake. 回答1: Try the following: import glob import pandas as pd #