Can I, for example, copy this number from one file to another?
inp = int(input("Enter your number:"))
I want to copy the inp to another file and I want to use the number in the other file,like this
another file:
print("", inp)
Can I do this and thank you.
file1:
input_num = int(input('Enter a number: '))
file2:
from file1 import input_num
num = input_num
You could write it in a function, then import that function in the other file.
input.py
def input_number():
inp = int(input("Enter your number"))
return inp
Other file:
from input import input_number
inp = input_number()
print("", inp)
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.