Hi I want to try to import some variables from one file to another but I still can't find the correct way to do it.
The variables I want to import are these:
introduce_product
enter_price
enter_brand
This is the code of the file where the variables are:
def button_agree (self):
introduce_product = self.Inp_product_name.text ()
enter_price = self.Inp_price_name.text ()
enter_brand = self.Inp_brand_name.text ()
Does anyone know how to import them correctly into a file? Thanks if you answer!
If you have two .py files in the same directory, say
var.py:
variable = 23
main.py:
import var
print(var.variable)
output:
23
If you're having errors with this, also try to create an empty python file named _ init _.py
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.