When doing;
a_file = open('E:\Python Win7-64-AMD 3.3\Test', encoding='utf-8')
…you’re trying to open a directory as a file, which may (and on most non UNIX file systems will) fail.
Your other example though;
a_file = open('E:\Python Win7-64-AMD 3.3\Test\a.txt', encoding='utf-8')
should work well if you just have the permission on a.txt
. You may want to use a raw (r
-prefixed) string though, to make sure your path does not contain any escape characters like \n
that will be translated to special characters.
a_file = open(r'E:\Python Win7-64-AMD 3.3\Test\a.txt', encoding='utf-8')
Related Posts:
- Understanding the main method of python [duplicate]
- TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array
- TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array
- Error in Python script “Expected 2D array, got 1D array instead:”?
- ‘str’ object has no attribute ‘decode’. Python 3 error?
- How to draw a line with matplotlib?
- How to open a file using the open with statement
- How can I represent an ‘Enum’ in Python?
- Relative imports – ModuleNotFoundError: No module named x
- Relative imports – ModuleNotFoundError: No module named x
- How to uninstall a package installed with pip install –user
- How do I upgrade the Python installation in Windows 10?
- not all arguments converted during string formatting.. NO % variables
- Python Variable Declaration
- Relative imports in Python 3
- Best way to convert string to bytes in Python 3?
- PermissionError: [Errno 13] Permission denied
- What is setup.py?
- FileNotFoundError: [WinError 2] The system cannot find the file specified:
- How to correct TypeError: Unicode-objects must be encoded before hashing?
- How to remove EOFError: EOF when reading a line?
- syntaxerror: “unexpected character after line continuation character in python” math
- TypeError: cannot unpack non-iterable NoneType object
- Python inline if statement
- How to install python3 version of package via pip on Ubuntu?
- How to copy a dictionary and only edit the copy
- Could not find a version that satisfies the requirement tensorflow
- TypeError: ‘float’ object not iterable
- Importing class from another file [duplicate]
- pip or pip3 to install packages for Python 3?
- csv.Error: iterator should return strings, not bytes
- Python Key Error=0 – Can’t find Dict error in code
- what does the __file__ variable mean/do?
- pandas: merge (join) two data frames on multiple columns
- Are dictionaries ordered in Python 3.6+?
- TypeError: method() takes 1 positional argument but 2 were given
- TypeError: write() argument must be str, not bytes (Python 3 vs Python 2 )
- How can I get a list shape without using numpy?
- Why am I getting this syntax error: keyword can’t be an expression
- Pythonic way to create a long multi-line string
- ctypes – Beginner
- How can I flush the output of the print function?
- What is the purpose of “pip install –user …”?
- ‘pip3’ is not recognized as an internal or external command, operable program or batch file
- TypeError: ‘encoding’ is an invalid keyword argument for this function
- Generate random sentences in python
- What is the Python 3 equivalent of “python -m SimpleHTTPServer”
- What does -> mean in Python function definitions?
- ‘dict’ object has no attribute ‘has_key’
- How to clamp an integer to some range?
- How do you use subprocess.check_output() in Python?
- List attributes of an object [duplicate]
- ValueError: unsupported pickle protocol: 3, python2 pickle can not load the file dumped by python 3 pickle?
- Convert bytes to int?
- ValueError: unsupported pickle protocol: 3, python2 pickle can not load the file dumped by python 3 pickle?
- Is there an operation for not less than or not greater than in python?
- Simple prime number generator in Python
- Background color for Tk in Python
- How to troubleshoot an “AttributeError: __exit__” in multiproccesing in Python?
- How to save a dictionary to a file?
- Python FileNotFound
- Type error Unhashable type:set
- How do I get monitor resolution in Python?
- Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings
- Python map object is not subscriptable
- .pyw files in python program
- Replacing a character from a certain index
- ImportError: No module named ‘google’
- Ruby equivalent for Python’s “try”?
- Unable to convert 3d ply file image to 2d image
- Get a random sample with replacement
- NameError: global name ‘unicode’ is not defined – in Python 3
- Conda command is not recognized on Windows 10
- TypeError: int() argument must be a string, a bytes-like object or a number, not ‘list’
- Python TypeError: non-empty format string passed to object.__format__
- AttributeError: ‘Series’ object has no attribute ‘reshape’
- ImportError: No module named ‘django.core.urlresolvers’
- How to do a Sigma in python 3
- Python 3: Multiply a vector by a matrix without NumPy
- How to fix “Can’t find a default Python” error
- TypeError: ‘newline’ is an invalid keyword argument for this function
- Python High Pass Filter
- environment variables PYSPARK_PYTHON and PYSPARK_DRIVER_PYTHON
- Python: urllib.error.HTTPError: HTTP Error 404: Not Found
- Decode Hex String in Python 3
- “This constructor takes no arguments” error in __init__
- ValueError: cannot switch from manual field specification to automatic field numbering
- How to embed image or picture in jupyter notebook, either from a local machine or from a web resource?
- Meaning of list[-1] in Python
- Tkinter error: Couldn’t recognize data in image file
- How to install Openpyxl with pip
- How can I count time in Python 3?
- What is the correct format to write float value to file in Python
- Using strip() to clean up a string
- “E: Unable to locate package python3-pip”
- How to print a specific row of a pandas DataFrame?
- Get all object attributes in Python?
- Accessing dict_keys element by index in Python3
- KeyError: ‘plotly_domain’
- TypeError: ‘zip’ object is not subscriptable