A few days ago received a task, from Gerrit on the SSH command to get some commit-related data into a text document, and then put the data into Excel. The data format is as shownIt is observed that the existence of data in a text document conforms to a certain format, and that processing and writing to an Excel document through Python reads and regular expression
A few days ago received a task, from Gerrit on the SSH command to get some commit-related data into a text document, and then put the data into Excel. The data format is as shownIt is observed that the existence of data in a text document conforms to a certain format, and that processing and writing to an Excel document through Python reads and regular expression
The format output string in Python uses the format () function, the string is the class, you can use the method;
Python is a fully object-oriented language, and everything is an object;
The parameters of the string are represented by {NUM}, 0, representing the first parameter, 1, representing the second parameter, an
# # This article is based on Python3, there may be partial content not fit Python21. Output of the simplest string:' popma is so cool ' Print (STR1)Output: is so cool2. '%s ' formatted string output:When formatting a string, there is a format character in the string, and the string becomes a template;For example:' %s is so cool ' %'popma'print(str2)The output is the same as above, you can try it.But if there are multiple
The format () function is used to format the output string in Python. a string is a class and can be used as a method. Python is a fully object-oriented language and everything is an object; string parameters are represented by {NUM}, 0, indicating the first parameter, 1, indicating the second parameter, followed by in
Python is used to determine the mp3 format and pythonmp3 format.
The project uses the mp3 format for sound playback. When an mp3 file does not play sound in the program, it is found to be a wav file, but ended with an mp3 file. To import a resource in the MP3 format, you mus
Python log format output and time format
formatter = logging.Formatter("%(asctime)s %(levelname)s %(message)s","%Y%b%d-%H:%M:%S")
The above % Y and so on are time formats, so to understand the above, Let's first look at the Python time format.
% A-abbreviated weekday na
INSERT into TTT (Nsame, ID, age) VALUES (' AAA ', ' 201023210816 ', ' 22 ');Change the SQL format above to the following formatAaa|201023210816|22Import oslists=[]paths = OS.GETCWD () for root,dirs,files in Os.walk (' Wfyh '): For fn in files: lists.append (FN) For NMB in lists: dfile=open ("wfyh\\" +NMB, ' R ') nmbb=nmb.replace ('. sql ', ') ofile=open ("wf_test\\" + nmbb+ '. txt ', ' W ') lists=[] for line in dfile: m=li
Read Catalogue
Grammar
By location
by keyword
Through object properties
by subscript
Fill and align
Accuracy and type F
In-process conversion
Thousands separator
Python since 2.6, a new format string function Str.format (), powerful, can replace the original%Note : The following operating version is python2.7Mapping example back to top syntaxby {} and: replace%B
The Python string is formatted with the character% format 1 format 2 character% (variable 1, variable 2), and the% format represents the type that accepts the variable. Examples of simple uses are as follows
# Example: String formattingName = ' 17jo 'print ' www.%s.com '%name>> www.111cn.net
Name = ' 17jo 'Zone = ' c
Python judges the mp3 format and pythonmp3 formatDetermine mp3 format using python
The project uses the mp3 format for sound playback. When an mp3 file does not play sound in the program, it is found to be a wav file, but ended with an mp3 file. To import a resource in the M
The format string in Python currently has two camps:% and format, which one should we choose?Since Python2.6 introduced the format-formatted string method, I think the% or format is not a problem at all. Don't believe you look down.% of disadvantage:# define a coordinate val
The Python string is formatted using the "character% format 1% format 2 characters"% (variable 1, variable 2), and the% format represents the type of the accepted variable. Simple examples of use are as follows:
# Example: String formatting
Name = ' 17jo 'print ' www.%s.com '%name>> www.17jo.com
Name = ' 17jo 'Zone =
Formatter = logging. formatter (% (asctime) s % (levelname) s % (message) s, % Y % B % d-% H: % M: % S) the above % Y and so on are time formats, so to understand the above, let's first look at the Python time format. % A-abbreviatedweekdayname %
formatter = logging.Formatter("%(asctime)s %(levelname)s %(message)s","%Y%b%d-%H:%M:%S")
The above % Y and so on are time formats, so to understand the above, let
Formatter = logging. Formatter ("% (asctime) s% (levelname) s% (message) S", "%y%b%d-%h:%m:%s")The above%y is a time format, so to understand what to indicate above, first look at the Python time format.
%a-abbreviated Weekday Name
%a-full Weekday Name
%b-abbreviated Month Name
%b-full Month Name
%c-preferred Date and time representation
%c-century
Python converts m3u8 format to mp4 video format, pythonm3u8
Open the engine: Recently, some videos have been downloaded using the mobile QQ browser, and more videos occupy the phone memory. So I want to upload the downloaded videos to my computer and save them, later, we found that all these videos are in m3u8 format a
Python implements bulk conversion of SVG format into png, pdf format code sharing, pythonsvg
Need to install cairosvg module in advance, http://cairosvg.org/download/
Code:
#! Encoding: UTF-8import cairosvgimport OS loop = Truewhile loop: svgDir = raw_input ("Enter the SVG file directory") if OS. path. exists (svgDir) and OS. path. isdir (svgDir): loop = False el
Implementation effect
Convert the /img 1000 pictures that are located in the directory .png into a format and store them in a .webp img_webp folder.
SOURCE Picture Catalog
Target Picture Directory
About batch generation of 1000 pictures, you can refer to this article: the use of Python batch generation of any size picture
implementation example
Import glob
import OS
import threading
from PIL i
Tags: style blog color os sp for file div onINSERT into VALUES ('AAA'201023210816') ;Change the SQL format above to the following formatAaa|201023210816|22Importoslists=[]paths=OS.GETCWD () forRoot,dirs,filesinchOs.walk ('Wfyh'): forFninchfiles:lists.append (FN) forNmbinchLists:dfile=open ("wfyh\\"+NMB,'R') NMBB=nmb.replace ('. SQL',"') ofile=open ("wf_test\\"+nmbb+'. txt','W') Lists=[] forLineinchdfile:m=line.split ('(') [2].replace (');',"'
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.