Python2 transcoding error problem

A rookie uses python2.7, transcoding to keep reporting AttributeError: "file" object has no attribute" decode"
the transcoding code is:
import chardet
from sys import argv
script, filename = argv
ready = open (filename, "r +")
print chardet.detect (ready.read ())
print (ready.decode ("windos-1252")) .encode (" unicode")

keep reporting errors, not even changing unicode to utf- 8 and gbk. May I ask you what"s wrong with this?

Mar.25,2021

ready is file,
ready.read () is the file content.

  

ready is a file object, which does not have an encode method. What you need is to read out the contents of the file, assign a variable to it, and then guess the encoding. 30% of the possibility is too small, indeed not very accurate.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b396f4-2c19e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b396f4-2c19e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?