#!/usr/bin/env python3 import os import sys # 打印当前目录 print("当前工作目录 : %s" % os.getcwd())
#!/usr/bin/env python3 import os import sys path = '/proj/serdes/user/mtk16288' dirs = os.listdir(path) # 输出所有文件和文件夹 if __name__ == '__main__': for file in dirs: print(file)
#!/usr/bin/env python3 import os import sys #打印当前目录的绝对路径 path = os.path.abspath(r".") print(path)
#!/usr/bin/env python3 import os import sys os.system('ls')
#!/usr/bin/env python3 import os import sys file_path = '/proj/serdes/user/mtk16288/ul_l1_rx_feq_test.sv' path = os.path.split(file_path) print(file_path)
#!/usr/bin/env python3 import os import sys path = '/proj/serdes/user/mtk16288' Path1 = 'proj' Path2 = 'serses' Path3 = 'user' #字符串拼接 Path10 = Path1 + Path2 + Path3 print ('Path10 = ', Path10) #path拼接 Path20 = os.path.join(Path1, Path2, Path3) print ('Path20 = ', Path20)
#!/usr/bin/env python3 import os import sys file_path = '/proj/serdes/user/mtk16288/ul_l1_rx_feq_test.sv' print(os.path.dirname(path))
#!/usr/bin/env python3 import os import sys file_path = '/proj/serdes/user/mtk16288/ul_l1_rx_feq_test.sv' path = os.path.basename(file_path) print(path)