• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

gisoracle

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

arcgis python 更新日期为随机数

#coding:UTF-8
import time
import random
import re

# 根据时间返回,返回随机年月日时间
def getRandomDate(sYear, sMonth, sDay, eYear, eMonth, eDay):
    a1=(sYear,sMonth,sDay,0,0,0,0,0,0)
    a2=(eYear,eMonth,eDay,23,59,59,0,0,0)
    start=time.mktime(a1)
    end=time.mktime(a2)
    t=random.randint(start,end)
    date_touple=time.localtime(t)
    date=time.strftime("%Y/%m/%d",date_touple)
    return date

调用:getRandomDate(2010,1,1,2019,1,1)

关注微信公众号,学习更多

posted on 2019-09-03 10:39  gisai  阅读(425)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3