python - Python 代码部分无法在 Jupyter 笔记本中运行
问题描述
我正在构建一个代码来下载一些数据并重命名文件。当我在 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")
B部分
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")
解决方案
推荐阅读
- jquery - 仅适用于有效日期和 MM/DD/YYYY 格式的 JQuery 日期验证
- javascript - 在没有递归/承诺的情况下无限期重复异步功能
- javascript - 如何在我的视图和所有屏幕中居中我的 react-native svg
- python - 为什么我的 PySpark 数据框连接操作写入空结果?
- python - 错误的层尺寸 Keras
- python - NameError:没有为 Selenium 定义名称“驱动程序”
- r - R - 如何将表达式传递给集群(在并行包中)
- css - 如何阻止 div 在 Safari 中重叠
- typescript - 具有构造函数的对象的条件类型
- flutter - viewportFraction < 1.0 的 PageView 非居中对齐