码迷,mamicode.com
首页 >  
搜索关键字:python3 datetime    ( 17497个结果)
python2和python3编程差异杂谈(-)
python2 默认编码ascii 在使用中文时要显示的声明 #-*-encoding:utf-8-*- python3 默认编码utf-8,良好的支持了中文输入 python2: print函数没括弧,当然加了括弧也可以 Python3:print函数必须加括弧 Python2 和 3的区别:2有 ...
分类:编程语言   时间:2017-10-25 21:17:09    阅读次数:156
Python3-笔记-B-003-数据结构-元组tuple( )
# 元组[有序不变序列](不可修改)def tuples(): # 元组 # 创建 (类似于列表的数据存储方式,但是不能修改) tuples = ("柳岩", 21, "女") tuples = tuple(["a", "b", "c"]) # 将 列表 转为 元组 (注:将字典转为元组会损失数据) ...
分类:编程语言   时间:2017-10-25 18:15:19    阅读次数:177
Python3-笔记-D-001-异常与断言
import sys# 捕获异常 (可灵活组合) def excep(): # - try except - try: print(ex) except: # 捕获所有异常 print("捕获异常!") try: print(ex) except: # 通过函数获取异常信息 types, value ...
分类:编程语言   时间:2017-10-25 18:12:15    阅读次数:243
Python3-笔记-A-001-基本语法
def helloworld(): # Hello World print("Hello World!") # 字符串用`'`或者`"`包裹 print("中文") # 代码中包含中文时(包含中文注释)需要在首行添加该注释(#coding=utf-8)def explanatorynote(): # ...
分类:编程语言   时间:2017-10-25 18:11:42    阅读次数:260
Python3-笔记-E-001-库-随机数random
import random # 随机数模块 lists = [1, 2, 3, 4, 5] def demo(): # 产生[0, 100]随机整数 num = random.randint(0, 100) print(num) # 产生[0, 100)随机浮点数 fnum = random.uni ...
分类:编程语言   时间:2017-10-25 18:08:58    阅读次数:230
Python3-笔记-B-005-数据结构-字符串str
# 字符串[有序不可变Unicode序列]def strs(): # 创建字符串 strs = "Hello World!" # 字符串用 '/ " / ''' / """ 包裹 strs = """可多行的字符串""" strs = str(123) strs = str({1, 2, 3}) # ...
分类:编程语言   时间:2017-10-25 18:07:53    阅读次数:249
Python3-笔记-B-006-数据结构-双向队列deque
from collections import deque# 双向队列[有序序列] (封装list)def deques(): # 双向队列,线程安全,队列两端添加和弹出复杂度为O(1),效率很高 # 创建 lists = ["A", "B", "C", "D", "E"] # <class 'li ...
分类:编程语言   时间:2017-10-25 18:07:21    阅读次数:194
Python3-笔记-B-001-数据结构-列表list[ ]
# 列表[有序可变序列]def lists(): # 列表 # 列表可通过 append() / pop() 方法,作为栈使用 # 列表可通过 deque() 封装,作为双向队列使用 # 创建 lists = ["a", "b", "c"] # 列表 lists = list() # 空列表 lis ...
分类:编程语言   时间:2017-10-25 18:06:14    阅读次数:185
Python Tuple(元组) min()方法
描述 Python 元组 min() 方法返回元组中元素最小值。 语法 min()方法语法: 参数 tuple -- 指定的元组。 返回值 返回元组中元素最小值。 实例 以下实例展示了 min()函数的使用方法: 以上实例输出结果如下: ...
分类:编程语言   时间:2017-10-25 18:05:50    阅读次数:143
Python3-笔记-B-002-数据结构-字典dict{ }
def dics(): # 字典 # 创建(由 键值对(key:value) 组成) dics = {1: "a", 2: "b", 3: "c"} dics = dict() # 创建空字典 dics = dict([(1, "a"), (2, "b")]) # (序列)转为字典 (列表序列: d ...
分类:编程语言   时间:2017-10-25 18:04:15    阅读次数:236
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!