Expected type 'optional[bytes]' got 'str' instead
Daiyue Weng
daiyueweng at gmail.com
Tue Sep 13 07:06:16 EDT 2016
Hi, I have the following piece of code,
rootPath = os.path.abspath(__file__)
rootPath = (rootPath.rsplit('\\', 1)[0]).rsplit('\\', 1)[0]
PyCharm inspection gave me warning on argument '\\' of the 2nd rsplit,
Expected type 'optional[bytes]' got 'str' instead
If I changed it to,
rootPath = (rootPath.rsplit('\\', 1)[0]).rsplit(b'\\', 1)[0]
Python game me errors,
TypeError: Can't convert 'bytes' object to str implicitly
How to fix it?
cheers
More information about the Python-list
mailing list