Home > other >  Python problem
Python problem

Time:09-26

have bosses know why, I import functions and classes in the same subfolder is an error, in the home folder can import directly, this is what reason, for bosses to explain

CodePudding user response:

And I if you want to import the same subfolder of classes and functions in addition to change the storage location, what method you

CodePudding user response:

First take a look at your Car. Py of code to write some what?

CodePudding user response:

In the environment variable directory can be?

CodePudding user response:

The class Car:
"" "simple try to simulate the car "","
Def __init__ (self, the make, model, year) :
"" "" "" initialization describe properties
Self. Make=make
The self. The model=model
The self. The year=year
Self. Odometer_read=0

Def get_descriptive_name (self) :
"" "return neat description information "","
Long_name=STR (self. Year) + "" + self. Make +" "+ self. The model
Return long_name. Title ()

Def read_odometer (self) :
"" "print a points out that the car mileage of message "" "
Print (" This car has "+ STR (self. Odometer_read) +" miles on it ")

Def update_odometer (self, mileage) :
"" "sets the odometer reading to the specified value
It is forbidden to the odometer reading back "" "
If the mileage & gt;=self. Odometer_read:
Self. Odometer_read=mileage
The else:
Print (" You can 't roll back an odometer.
")
Def increment_odometer (self, miles) :
"" "will increase specified values odometer reading "" "
Self. Odometer_read +=miles

CodePudding user response:

I don't really understand this play is on the HelloWorld folders can be, in other words not a folder

CodePudding user response:

The from your folder. The package name import your module (Car)

CodePudding user response:

Can excuse me specific example

  • Related