This is mainly because I don't want to let myself get old and find the old code I have previously written. it is both laborious and easy to get bored. So we can put the summary here. This is mainly because I don't want to let myself get old and find the old code I have previously written. it is both laborious and easy to get bored. So we can put the summary here.
Parse string into time object and calculate the interval (in seconds)
# Calculate the difference between the two timestamps import timefrom datetime import datetimefmt = "% Y-% m-% dT % H: % M: % S. % fZ "#2016-02-18T12: 22: 22.123456Ztime1 _ obj = datetime. strptime (time1, fmt) time2_obj = datetime. strptime (time2, fmt) time_interval = int (time. mktime (time2_obj.timetuple ()-time. mktime (timestamps obj.timetuple ()))
Call shell command in Python script
# The combination of Python and Shell is useful in practical research. import subprocesssubprocess. call (["ls", "-l"], cwd = ".")
Read xml from file_path
import xml.etree.ElementTree as ETtree = ET.parse("test.xml")root = tree.getroot()# apply dom operations on root
For more articles about Python, see PHP!