在Pycharm(Python 3.8)上运行python文件时出现问题

时间:2020-03-18 22:30:54

标签: python-3.x pycharm

我编写了一个python文件,执行后应在本地目录中创建一个csv文件。即使执行成功完成,python文件也不会在本地目录中创建csv文件。我的代码和输出屏幕截图如下:

SELECT ed.monthNameYear, ed.monthName,        
       COUNT(*),
       SUM(COUNT(*)) OVER (ORDER BY ed.monthNameYear)
FROM (SELECT DATE_FORMAT(`reservation_for`,'%Y-%m') as monthNameYear,
             DATE_FORMAT(`reservation_for`, '%M %Y') as monthName, 
             email,
             COUNT(*) AS cnt
      FROM `tablename`
      GROUP BY email, DATE_FORMAT(`reservation_for`, '%Y-%m'),
            DATE_FORMAT(`reservation_for`,'%M %Y')
      HAVING COUNT(*) > 1 
     ) ed
GROUP BY ed.monthNameYear, ed.monthName;

Source

Pycharm Project Structure as Source Folder

1 个答案:

答案 0 :(得分:0)

由于当前工作目录(cwd)问题,很有可能将其保存在您不希望的地方。

按照PyCharm current working directory更改PyCharm中的当前工作目录,或使用代码明确更改它:

import os # put these lines at the top of your script
os.chdir(r"/Users/bsulin/PycharmProjects/StockNewsWebScraper/")