file_version = pe.VS_FIXEDFILEINFO.FileVersionMS AttributeError: 'list' object has no attribute 'FileVersionMS'
时间: 2023-10-16 19:32:26 浏览: 110
This error occurs because the variable 'file_version' is a list object, and the attribute 'FileVersionMS' is not defined for a list object. To fix this error, you need to ensure that 'file_version' is a valid object that contains the required attributes.
One possible solution is to use the 'GetFileVersionInfo' method from the 'win32api' module to retrieve the file version information. Here's an example code snippet:
```
import win32api
import win32con
# Replace 'file_path' with the path to your file
file_path = 'C:/path/to/your/file.exe'
# Get the file version information
file_version_info = win32api.GetFileVersionInfo(file_path, '\\')
# Extract the file version numbers
file_version = (file_version_info['FileVersionMS'] >> 16, file_version_info['FileVersionMS'] & 0xFFFF,
file_version_info['FileVersionLS'] >> 16, file_version_info['FileVersionLS'] & 0xFFFF)
# Print the file version
print('File version:', '.'.join(map(str, file_version)))
```
This code should retrieve the file version information and print it in the format 'MAJOR.MINOR.PATCH.BUILD'.
阅读全文