#coding:utf-8
import datetime
class My_Util():
@classmethod
def toTime(cls):
print(datetime.date(2018,7,27))
if __name__=="__main__":
My_Util.toTime()
————————————————————————————————————————————————————————
#coding:utf-8
import math
import datetime
# 模块名字.函数或者类
# math.sqrt()
from os import path as mypath
# from os import *
# 类名.函数
mypath.isfile("")
# listdir("目录")
import my__module
my__module.My_Util.toTime()
——————————————————————————————————————————————————————
#coding:utf-8
list1 = [1 for x in range(0,10) ]
list1 = [ [x,y] for x in range(0,10) for y in range(1,4)]
list1 =[x for x in range(1,100) if x%2==1 ]
list1 =[ [x-2,x-1,x] for x in range(1,100) if x%3==0]
print(list1)
——————————————————————————————————————————————————————
#coding:utf-8
import pymysql
conn =pymysql.connect("127.0.0.1","root","123123","test",3306)
# pymysql.connect(host="localhost",port=3306)
c= conn.cursor()
# c.execute("select count(*) from emp")
c.execute("select * from emp where sal > %d"%2500)
print(c.fetchall())
conn.close()
——————————————————————————————————————————————————
#coding:utf-8
import numpy as np
# 第一种
# arr=[[1,2,3],[4,5,6]]
# a = np.array(arr)
# print(a.shape)
# print(a.ndim)
# print(a.dtype)
#第二种 向量== [1,2,3,4]
a =np.arange(1,17).reshape((2,2,2,2))
# a= np.random.randint(0,10,16).reshape((2,2,2,2))
# a =np.random.randn(9) # 随机生成一个正态分布的数列
# print(a)
# print(a)
print(a[1][0][0][1])
print(a[1,0,0,1])
# 第三种
a= np.zeros((3,3))
a= np.ones((3,3))
a=np.empty((3,3)) # None
# print(a)
————————————————————————————————————————————————————
#coding:utf-8
import numpy as np
a =np.random.randint(0,10,(4,5))
print(a)
print("-"*30)
# 第三行第三列
# print(a[2,2])
#第二行,前三列
print(a[1,:3])
# 第一,三,四行的前三列
print(a[[0,2,3],:3])
# 中间两行的后三列
print(a[1:3,-3:])