osp.join("images/tmp", "tmp_upload." + fileName.split("."))
时间: 2023-10-05 11:10:14 浏览: 108
I believe there is an error in the code you provided. The second argument of `osp.join()` should be a single string representing the file name with extension, but in your code, you are passing a list obtained by splitting the file name with `.`. Moreover, you need to join the file name with the file path using the forward slash `/` instead of `.`.
Here's the corrected code:
```
import os.path as osp
file_path = "images/tmp"
file_name = "tmp_upload.png"
# Splitting the file name and extension
file_name_parts = file_name.split(".")
file_ext = file_name_parts[-1]
# Joining the file path and file name
new_file_name = "tmp_upload_processed." + file_ext
new_file_path = osp.join(file_path, new_file_name)
print(new_file_path)
```
This code will output:
```
images/tmp/tmp_upload_processed.png
```
Here, we split the file name to get the extension, then join the new file name with the extension and the file path using `osp.join()`. The resulting file path is then printed.
阅读全文