devwiki:python

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
devwiki:python [2021/12/16 19:20] – [django] yingdevwiki:python [2022/05/02 14:34] – [system command modules] ying
Line 584: Line 584:
 list=[1,2,3,4,5,6] list=[1,2,3,4,5,6]
 seq=list[::-2] # [6,4,2] seq=list[::-2] # [6,4,2]
 +
 +# list to pair list
 +info = ['name','John', 'age', '17', 'address', 'abc']
 +info_pair = zip(info[::2], info[1::2])
 +# [('name', 'John'), ('age', '17'), ('address', 'abc')] 
  
 # list flatten, and remove duplicates # list flatten, and remove duplicates
Line 1130: Line 1135:
 subprocess.Popen([r'D:\Dev\Pipeline\PyDesktop\CompFolder\CompFolder.bat'], env=env2) subprocess.Popen([r'D:\Dev\Pipeline\PyDesktop\CompFolder\CompFolder.bat'], env=env2)
 </code> </code>
 +  * subprocess a console app and get return, and optionally hide the pop up console when call <code pyhton>
 +# hide popup console for win platform only
 +startupinfo = subprocess.STARTUPINFO()
 +startupinfo.dwFlags |= 1 #subprocess.STARTF_USESHOWWINDOW
 +# startupinfo.wShowWindow = subprocess.SW_HIDE #(optional)
  
 +info=subprocess.Popen( '{0}'.format(app_path),stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE,  startupinfo=startupinfo)
 +out, err = info.communicate()
 +</code>
 ==== string related ==== ==== string related ====
  
  • devwiki/python.txt
  • Last modified: 2024/03/25 06:36
  • by ying