- error "Invalid argument" is reported when there is an English question mark in the path of the parameter file when using the open function of python
- asked on stackoverflow, and a boss told me, "Install linux.." Or something else that isn"t Windows. Alternatively, accept the fact that a file name can"t contain a question mark. (install linux. Or other systems that are not Windows. Or, accept the fact that the file name cannot contain a question mark.) "
- the current solution is to replace the English question mark with the Chinese question mark, but it doesn"t feel elegant enough. What if there are other characters that I don"t know that I"m not allowed to use? Do you have a better way to deal with it?
the code snippet that reports the error is as follows:
savePath = "E:\\Desktop\\output\\?.html"
file = open(savePath, "wb")
the error message is as follows:
Traceback (most recent call last):
File "Main.py", line 35, in <module>
crawler.testSaveContent("E:\\Desktop\\output\\?.html")
File "E:\Desktop\MyCrawler.py", line 77, in testSaveContent
file = open(savePath, "wb")
OSError: [Errno 22] Invalid argument: "E:\\Desktop\\output\\?.html"
python version: 3.6.3
operating system: win10