首页 > 其他分享 >time,random,datetime

time,random,datetime

时间:2023-04-23 23:33:28浏览次数:31  
标签:mylist random datetime time print import

 

 

import time
print(time.time())

import random
from random import randint

random.choice

import datetime
year = datetime.datetime.now().year
month = datetime.datetime.now().month
print(year , month)

a=2
b=8
c=9
a,b,c = c,a,b
print(a,b,c)

tuple = (1,2,3,4)
print(tuple[1:3])
# tuple[2]=3 出错,tuple不能修改

st1,st2,st3 = (1,2,3) # 等效于 st1,st2,st3 = 1,2,3   如果不加括号,将会被自动视为元组
print(st1,st2,st3,sep=' & ')

mylist = [3,'this',6.2]
mylist.extend([3,4])
print(mylist)
mylist.pop()
print(mylist)
print(mylist.index('this'))
mylist.sort()
print(mylist)

  

标签:mylist,random,datetime,time,print,import
From: https://www.cnblogs.com/sangern/p/17348127.html

相关文章

  • java调用GDAL,接口运行一次出现A fatal error has been detected by the Java Runtime
    参考文章:https://www.jianshu.com/p/4bffe29e3a02问题描述:通过调用GDAL写的SpringBoot接口,第一次访问成功,第二次报错,显示报错的位置为gdal库。尝试了很多方法https://www.cnblogs.com/jokingremarks/p/15132599.html#!comments仍然不成功,感觉应该是第二次运行接口时,进行垃圾回......
  • Educational Codeforces Round 39 (Rated for Div. 2) -- D. Timetable (DP)
    写得很折磨人,每次dp都写个一个多小时,写出来明明觉得不难.题目大意:可以进行K次操作,把删除1,进行k次操作后每行第一个1和最后一个1的位置相减的绝对值加1得到的结果最小。做法:每次肯定是要从左删或者从右边删,然后顺着这个思路,先把每行的进行小于等于k次操作时,每行最小......
  • codeforces 172B B. Pseudorandom Sequence Period(暴力)
    题目链接:codeforces172B题目大意:给出生成元,和递推式,求一个有限群元素的个数题目分析:暴力求取循环节即可,因为元素个数不会超过mod的大小,所以暴力法复杂度仅仅是O(105)AC代码:#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<cstdio>#de......
  • Shortest time(最短时间)
    这题怎么这么难啊(恼 有若干个城市,它们之间有道路连通,可以互相到达,从一个城市到另一个城市时间为1。现在给出起点城市A,终点城市B,和N条道路。问从A到B最短时间。input第一行A,B,N(A,B,N<=30),B为最大城市标号接下来N行,每行两个数x,y,表示城市x和城市y有道路相连。out......
  • nginx日志中出现proxy_pass代理地址timeout
    背景:  开发发现测试环境业务异常,影响新需求上线,排查日志中发现nginx日志中出现proxy_pass代理地址timeout报错,直接使用代理地址curl没问题,重启nginx就好了。由于是开发自建自运维的nginx服务器,且出问题当天运维有对服务器进行审计操作,开发便把这口锅甩给我们运维人员!!!排查问题: ......
  • Hydro Tools:System.Runtime.InteropServices.COMException (0x80004005)
     在使用hydrotools的时候报了这个错误 然后看到一个solution 这个设置一下 rasterworkspace要选择它默认的图层layer不是gdb,只有vectorworkspace才是gdb ......
  • odoo中 py3o的打印报告中,报告的名字如果要取当天的日期或其它日期时,如果要导包,import
    odoo中py3o的打印报告中,报告的名字如果要取当天的日期或其它日期时,如果要导包,import timedate.这种在report的名字中,是请允许使用eval 这个函数(出于安全考虑)可以使用下面的来替代时间'orderrecap%s'%(time.strftime("%Y-%m-%d",time.localtime())) 还有一种方法是......
  • bootstrap日期插件datetimepicker的简单使用
    <!DOCTYPEHTML><html><head><linkhref="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css"rel="stylesheet"><linkrel="stylesheet"type="text/cs......
  • random随机数的学习
    Linux中的随机数知多少原创 入门小站 入门小站 2023-04-2122:26 发表于湖北收录于合集#Linux766个入门小站分享运维技巧及10k+Stars的开源项目237篇原创内容公众号【Linux250个常用命令速查手册】关注【入门小站】,后台回复「1001」自取。Li......
  • time&datetime&string相互转换
    time&datetime&string相互转换importdatetimeimporttime#日期时间字符串st="2017-11-2316:10:10"#当前日期时间dt=datetime.datetime.now()#当前时间戳sp=time.time()#1.把datetime转成字符串defdatetime_toString(dt):print("1.把datetime转成......