python 3.4.2 urlib no attribute 'pathname2url'
Question:
Why is the next code not working? I cant find why.
import mimetypes
import glob, urllib
for file in glob.glob("C:\Users\joey\Desktop\school\ICOMMH"):
url = urllib.pathname2url(file)
print(file, mimetypes.guess_type(url))
The error message I get is:
AttributeError: 'module' object has no attribute 'pathname2url'
I am trying display all file typs of a directory. Is this a good way? Or is there a better way. I dont want to use the module magic.
Answers:
This function’s location has changed in Python 3. It is now urllib.request.pathname2url
.
Why is the next code not working? I cant find why.
import mimetypes
import glob, urllib
for file in glob.glob("C:\Users\joey\Desktop\school\ICOMMH"):
url = urllib.pathname2url(file)
print(file, mimetypes.guess_type(url))
The error message I get is:
AttributeError: 'module' object has no attribute 'pathname2url'
I am trying display all file typs of a directory. Is this a good way? Or is there a better way. I dont want to use the module magic.
This function’s location has changed in Python 3. It is now urllib.request.pathname2url
.