import oscmd = "cd ~/ & ls"os.system(cmd)
When multiple commands are connected with a &, they are actually run separately, that is, exit after cd to the root directory, and then run ls in the path where the file is run to view the directory in the current path.The result is as follows:
import oscmd = "cd ~/ && ls"os.system(cmd)
If two && are used to connect multiple commands, the result of the operation is to cd to the root directory first, and then check the files in the current directory on this basis. The result is as follows: