Skip to content

learn-python3-ex15.py  #11

Description

@divyang805

hello sir
i'm at ex15 of learn python 3 the hard way and want to convert content of file into integer but got no way to do that.

i tried converting variable to integer which is holding a file

int_txt = int(txt)

but it gives an error like typeerror

TypeError: int() argument must be a string, a bytes-like object or a number, not '_io.TextIOWrapper'
my whole code is like

`from sys import argv

script, filename = argv

txt = open(filename , encoding = "utf-8")

print(f"Here's your file {filename}:")
print(txt.read())
print(type(filename))`

i tried checking that the content of file is in string or what so i got it's in string

so need help @zedshaw

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions