python - Why are the file names coming with an extra single quote at the beginning?
问题描述
I am trying to dynamically name my output files in df.to_excel as shown below:
df.to_excel(r'C:\Users\excel_outputs\'Solved'+str(f), index = False)
Also, str(f) contains my input file name and changes every time. The resulting filenames I'm getting are:
'Solvedsheet1
'Solvedsheet2
'Solvedsheet3
I just want:
Solvedsheet1
Solvedsheet2
Solvedsheet3
解决方案
这是一个单一的字符串,所以....
f = 'sheet1'
x = r"C:\Users\excel_outputs\Solved"+str(f)
print(x)
结果....
C:\Users\excel_outputs\Solvedsheet1
推荐阅读
- integration-testing - 赛普拉斯:自定义断言
- styled-system - 样式系统自定义断点
- c# - 自动连接 WPF 中丢弃的形状
- python - 在python中按给定顺序对字符串列表进行排序
- java - 在java中用null填充ArrayList的最快方法是什么?
- php - 使用 PHP 量化大型档案中的文件
- splunk - 统计一个字段不同值的个数,得到每分钟的平均值
- php - ./vendor/bin/sail:第 42 行:docker-compose:找不到命令
- snowflake-cloud-data-platform - 具有维度建模的雪花数据库(星型模式)
- java - 获取接口的实现对象实例