Python amusing-Anhui fast three size single and double group 328+444The edge, not the depth, the sentiment, not the distance. How many fresh clothes angry horse, finally will be attributed to insipid. Only a steady accompany is the ink and blue period, the interpretation of the world's most beautiful friendship. Days shallow flow, just want to face the sun, and the years of gentleness. Because I believe tha
#!/usr/bin/env python#说明, I am responsible for the project has a large number of processing images, respectively, A2 A3 A4 and other specifications, and these images are stored together, in accordance with the relevant file sequence of the whole group; now let me count the total number of images and A2 A3 A4, after a night of effort, the code is now published as follows:#这里主要用到了Image这个模块, you need to download it yourself#路径注意事项: In Windows, you need t
#对lt列表里元素从小到大排序 #一, select Sort by LT = [3, 5, 2, 1, 8, 4] #求出lt的长度 n = Len (LT) #外层循环确定比较的轮数, X is subscript, lt[x] represents all elements of LT in the outer loop for x in Range (n-1): #内层循环开始比较 for y in Range (x+1,n): #lt [x] represents a specific element in the for Y Loop, and Lt [y] represents any one of the LT elements. if Lt[x]>lt[y]: #让lt [x] Compare each element in the LT list to find a small Lt[x],lt[y]=lt[y],lt[x] print (LT) #二, sort by bubble so
,) rather than '%.1f '%
Both can be executed correctly, but the latter is easily misjudged as a function that executes only one parameter number, leading to difficult-to-judge errors.
3. Keep up to 1 decimal places in megabytes--return str
Most operating systems typically display up to 1 decimal places
4. Automatically select the best unit
Algorithm Description:
1. From the English grammar point of view, only 1 uses the singular form. The other 0/decimals are in plural form. Bytes level invo
File Size friendly output and Python implementation,
When storing data in a database, Bytes is more precise, with high scalability and flexibility.
Some adaptation is required for output.1. Precautions and test code
The implemented function is getSizeInMb (sizeInBytes), and the general test code is
def getSizeInMb(sizeInBytes): return 0def test(sizeInBytes): print '%s -> %s' % (sizeInBytes, getSizeInM
# HEAPQ function: Calculate list maximum several values and minimum values # Syntax: Heapq.nlargest (n, List,[key]) # N denotes the largest or smallest number; The list is the object of the analysis; key is the sort key, not required import heapqlist_ num = [1, 4, 3, 2, 5]print ("Max one:", Max (List_num)) # Ask for the list of the largest two list_temp = Heapq.nlargest (2, List_num) print ("Max two:", list_t EMP) List_people = [ {' name ': ' Mike ', ' Age ': ' ", ' {' name ': ' Lee ', ' age
Import OS, sysfrom stat import *big_file_threshold = 6000L #1000000Ldict1 = {} # dict2 = {} # def treewalk (path): C2/>try: For i in Os.listdir (path): mode = Os.stat (path+ "/" +i). St_mode if S_isdir (mode) How to use Remove c:/xx Python implements the deletion of files of a specified size under a specified directory
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.