file_name, ext = line.strip().split('.'),too many values to unpack (expected 2)
时间: 2023-10-22 18:10:49 浏览: 36
This error message is indicating that the variable "line" contains a string with more than one dot (".") character, which means that there are more than two values being returned when the string is split at the dot. The code is expecting to split the string into two parts: the file_name and the extension, but it cannot do so if there are more than two parts.
To fix this error, you can either ensure that the string being passed to the split() method only contains one dot character, or modify the code to handle cases where there may be more than one dot character in the string. One possible solution could be to split the string by the last dot character, using rsplit() instead of split():
```
file_name, ext = line.strip().rsplit('.', 1)
```
This will split the string only once, starting from the right (hence the "r" in rsplit()), and return the file_name and extension as separate values.