Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 087cd15

Browse files
Update 07-常用函数.md
1 parent 0592415 commit 087cd15

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

‎07-常用函数.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- [文本相似度](#文本相似度)
1414
- [json解析](#json解析)
1515
- [日期格式清洗](#日期格式清洗)
16+
- [时间戳格式](#时间戳格式)
1617
- [众数占比](#众数占比)
1718
- [计算非空唯一值](#计算非空唯一值)
1819
- [分层抽样](#分层抽样)
@@ -387,6 +388,40 @@ time_trans(t)
387388

388389
------
389390

391+
### 时间戳格式
392+
393+
```python
394+
# 10位与13位时间戳
395+
import datetime
396+
import time
397+
def get_time_stamp10():
398+
# 生成13时间戳 eg:1540281250399895
399+
datetime_now = datetime.datetime.utcnow()
400+
# 10位,时间点相当于从UNIX TIME的纪元时间开始的当年时间编号
401+
date_stamp = str(int(time.mktime(datetime_now.timetuple())))
402+
# 3位,微秒
403+
data_microsecond = str("%06d"%datetime_now.microsecond)[0:3]
404+
date_stamp = date_stamp
405+
return int(date_stamp)
406+
407+
def get_time_stamp13():
408+
# 生成13时间戳 eg:1540281250399895
409+
datetime_now = datetime.datetime.utcnow()
410+
# 10位,时间点相当于从UNIX TIME的纪元时间开始的当年时间编号
411+
date_stamp = str(int(time.mktime(datetime_now.timetuple())))
412+
# 3位,微秒
413+
data_microsecond = str("%06d"%datetime_now.microsecond)[0:3]
414+
date_stamp = date_stamp+data_microsecond
415+
return int(date_stamp)
416+
417+
utctime = get_time_stamp10()
418+
utctime = get_time_stamp13()
419+
```
420+
421+
<br/>
422+
423+
------
424+
390425
### 众数占比
391426

392427
```python

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /