The
python time tuples are converted to timestamps and strings
1, time tuple –> Timestamp p>
import time
timeArray = time.localtime(time.time())
timeStamp = time.mktime(timeArray) # 时间戳:1600858387.0
2, time tuple –> String p>
timeDate = time.strftime("%Y-%m-%d %H:%M:%S", timeArray) # datetime.datetime:'2020-09-23 18:53:07'
timeDate = time.strftime("%Y-%m-%d", timeArray) # datetime.date:'2020-09-23'
div>
Read More:
- Python Time Module timestamp, Time string formatting and Conversion (13-bit timestamp)
- [Solved] ValueError: only one element tensors can be converted to Python scalars
- Python TypeError: not all arguments converted during string formatting [Solved]
- Python: LeetCode 43 Multiply Strings
- [Python] How to Sort a Group of Tuples Using the Sorted() Function
- Python: How to Set Line breaks and tabs for Strings
- Python traverses all files under the specified path and retrieves them according to the time interval
- An introduction to sys modules in Python and how packages are imported and used
- [Solved] TypeError: not all arguments converted during string formatting
- Pytorch Error: RuntimeError: value cannot be converted to type float without overflow: (0.00655336,-0.00
- Python3.7 AttributeError: module ‘time‘ has no attribute ‘clock‘
- [How to Fix]RuntimeError: Python is not installed as a framework, If you are using (Ana)Conda
- Invalid python sd, Fatal Python error: init_fs_encoding: failed to get the Python cod [How to Solve]
- [Solved] error: the following arguments are required (Default parameters are set)
- How to Solve Python WARNING: Ignoring invalid distribution -ip (e:\python\python_dowmload\lib\site-packages)
- Python: How to Create an Automatic Recording Program
- Python raspberry pie starts sending IP address to mailbox
- [Solved] NPM install Error: check python checking for Python executable python2 in the PATH
- [Solved] opencv-python: recipe for target ‘modules/python3/CMakeFiles/opencv_python3.dir/all‘ failed
- AttributeError: module ‘time‘ has no attribute ‘clock‘ [How to Solve]