1, a terminal command
- python “name.py”
2, in python environment where the script content
-
1
2
3a='head'
b='hehe'
print(a,b) Use import name of the script is executed, then you can use the following statement to view the display
-
1
2print (name.a)
print (name.b) A python in the same environment, the first import After loading, the use of import later there will be corresponding results show that a large column python script can use the reload (name) in this case to reload, in python3.0 ipm module needs to be loaded in order to use reload () function:
-
1
2from imp import reload
reload(name)
-
-
3, use the command to load a script from a variable or function
Also to name.py, for example, can use the following methods to run the script
-
1
2
3from name import a,b
type various a,b, the screen show:
head,hehe
4, the exec function
- Execution name name.py script: exec (open ( 'name.py') read ().)
python script
Guess you like
Origin www.cnblogs.com/dajunjun/p/11710877.html
Recommended
Ranking