How do I use the variables in this script in another python script?

Hello, prawns! I have a requirement, suppose I currently have a script a.py, which is as follows:

-sharp!/usr/bin/env python
-sharpcoding=utf-8

def aaa():
    Mode = "1"
    KeyWord = "hello"
    return Mode,KeyWord

def bbb(p):
    m=1
    n=2
    z=m+n+p
    return z

print (aaa())

now there are two questions:
1) what should a b.py do if he wants to get the Mode and mGrainn in a.py?
2) Why is the execution effect of the following script ("1percent," hello")? Instead of
("1century," hello")
103

-sharp!/usr/bin/env python
-sharpcoding=utf-8
from a import aaa,bbb
aaa()
bbb(100)

Dec.07,2021

in this case, just use the class directly


you are such a beginner.
the answer to the second question ('1century,' hello') is printed by print (aaa ()) , and comes from a.py . Although your b.py has been executed, there is no output result ( print ). Python import A package will run this package first, that is, a.py .

.

first question : cannot be done. Variables that act on the internal scope of the function cannot be obtained externally. You can only define them outside, or use classes, or global variables.

  python console input and output  

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-1b31750-2bd8c.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-1b31750-2bd8c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?