You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## The content of the file is a byte string, not a Unicode string.>>>withopen("/etc/passwd") asf:
... content=f.read()
>>>print(type(content))
<type'str'>>>>print(type(content.decode("utf-8")))
<type'unicode'>
Write a File
>>>file_content="Python is great!">>>withopen("check.txt", "w") asfile:
... file.write(file_content)
## If you are not using linux machine try to change the file path to read>>>withopen("/etc/hosts") asf:
... forlineinf:
... print(line, end='')
...
127.0.0.1localhost255.255.255.255broadcasthost
::1localhost