python - 带有多个文件的 os.path.join 不起作用
问题描述
我需要以下一些帮助,我似乎无法解决这个问题。
我需要用来path.join
构建我想要的路径。
base_name = os.path.dirname(__file__)
input_file = apache.log
output_filename = os.path.join(base_name,"test_",input_file)
但我得到/Users/test/Dropbox/Python/apache.log
而不是 /Users/test/Dropbox/Python/test_/apache.log
我不明白为什么......
谢谢
解决方案
怎么样:
base_name = os.path.dirname(__file__)
input_file = "apache.log"
output_filename = os.path.join(base_name,"test_",input_file)
推荐阅读
- javascript - 使用 jQuery 或 PHP 中的多个值按字母顺序对 JSON/Array 进行排序
- ruby-on-rails-5 - 如何回滚rails更新
- python - How to start two functions at the same time and only wait for the faster one?
- android - 更新 Android Studio 4.1 时出错。使用 TargetSDK 版本 29 时出错
- node.js - nginx:无效选项:“off”和entrypoint.sh::权限被拒绝
- android - 尝试在 Eclipse 中生成 APK
- asp.net-core - 使用 Saml2 和 Okta 作为服务提供者的 Asp.Net Core 3 中的用户身份验证
- azure - 在 Azure Devops 的拉取请求中显示接受标准
- spring-boot - Cassandra 读取查询返回空结果使用 springframework 数据 cassandra
- javascript - 我应该使用队列系统来处理多租户系统中的 PDF 文本识别吗?