'''help----os, help----glob''' import os import time import glob print(os.getcwd()) os.chdir('/home/tizen/share') print(os.getcwd()) path='/home/tizen/share/tools/python' path2='/home/tizen/share/tools/python/' '''don't care about / when join''' print(os.path.join(path2,'os_m.py')) print(os.path.join(path,'os_m.py')) print(os.path.expanduser('~')) '''get dir for ~, return path without \ in the end, but join don't care about it''' print(os.path.join(os.path.expanduser('~'), 'share/tools/python','os_m.py')) path3='/home/tizen/share/tools/python/os_m.py' (dirname,filename)=os.path.split(path3) print(dirname) print(filename) (name,ext)=os.path.splitext(filename) print(name) print(ext) os.chdir('/home/tizen/share/tools/python/') print(os.getcwd()) metadata=os.stat('os_m.py') print(metadata.st_mtime) print(time.localtime(metadata.st_mtime)) print(metadata.st_size) print(os.path.realpath('os_m.py')) '''analyze list''' a_list1=[2,6,8] a_list1=[ee*2 for ee in a_list1] print(a_list1) path5='/home/tizen/share/tools/python/*.py' print(glob.glob(path5)) print(glob.glob('*.py')) a_list3 = [os.path.realpath(ee) for ee in glob.glob('*.py')] print(a_list3) a_list4 = [f for f in glob.glob('*.py') if os.stat(f).st_size>1000] print(a_list4) a_list5=[[os.stat(f).st_size, os.path.realpath(f)] for f in glob.glob('*.py')] print(a_list5) '''analyze dict''' dict_13= {f:os.stat(f).st_size for f in glob.glob('*.py')} print(dict_13) dict_14={'a':1,'b':2,'c':3} dict_15={value:key for key,value in dict_14.items()} print(dict_15) '''analyze set''' set_13={1,2,4,6} set_14={f**2 for f in set_13} print(set_14) '''analyze tuple''' '''none'''