Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python代码在Jupyter笔记本中不起作用_Python - Fatal编程技术网

Python代码在Jupyter笔记本中不起作用

Python代码在Jupyter笔记本中不起作用,python,Python,我正在构建一个代码来下载一些数据并重命名文件。当我在Jupyter笔记本中通过在单独的单元格中运行A部分和B部分来测试它时,它可以工作,但在单个单元格中同时运行时它不工作 A部分 driver.find_element_by_xpath("//input[@value='Submit & Clear History']").click() time_to_wait = 10 time_counter = 0 while not os.path.exists(r"C:\Users\rkma

我正在构建一个代码来下载一些数据并重命名文件。当我在Jupyter笔记本中通过在单独的单元格中运行A部分和B部分来测试它时,它可以工作,但在单个单元格中同时运行时它不工作

A部分

driver.find_element_by_xpath("//input[@value='Submit & Clear History']").click()
time_to_wait = 10
time_counter = 0
while not os.path.exists(r"C:\Users\rkmaheshwaran\Downloads\CSV\Py-files"):
    time.sleep(1)
    time_counter += 1
    if time_counter > time_to_wait:break
print("done")
乙部

os.chdir(r"C:\Users\rkmaheshwaran\Downloads\CSV\Py-files")
for file in os.listdir(r"C:\Users\rkmaheshwaran\Downloads\CSV\Py-files"):
    src=file
    if src=='printcsvreports.csv':
        dst="inflowdata-" + time.strftime("%Y%m%d") + ".csv"
        os.rename(src,dst)
print("renamed")

错误消息具体说明了什么?我没有收到任何错误消息,但是在一起运行这些代码时文件没有重命名。获得的输出为:done