Implement some functions with python

1. If two .py files are in the same folder, one .py file can call the function in another .py file: from .py file name import function name.
2. Python reads the data in the json file
import json
with open("./config.json") as json_file:
config=json.load(json_file)
print(config[“max_depth”])
3. Stitching path:
from os .path import join
Join("a", "b"), it doesn't matter whether there is / after a or not, if there is, it will not be added, and it will not be added automatically 4. Create a
folder, create aa folder under the current path
from os import makedirs
makedirs("./aa")
5. Receive command line input when the program is running

2.py
a=input()
print(a)

python3 2.py
Enter 3 Enter
3 is displayed on the screen, that is, the input 3 is passed to the variable a

Guess you like

Origin blog.csdn.net/weixin_44594953/article/details/122913826