Skip to content

Commit 0f4d7e4

Browse files
committed
1.测试数据
1 parent bf1b28e commit 0f4d7e4

15 files changed

+364
-0
lines changed

com/lxl/base/Python1_JiBenYuFa.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import keyword
2+
# print(keyword.kwlist)
3+
'''
4+
多行注释1
5+
多行注释2
6+
'''
7+
"""
8+
多行注释1
9+
多行注释2
10+
"""
11+
# print(1+2)
12+
13+
str='''abx_123456 789GHK
14+
444'''
15+
16+
# print(str[2:])
17+
# print(str*2)
18+
19+
print(str[2:3:3],end="")
20+
21+
print('AAA')
22+
23+
#
24+
# import sys
25+
# for i in sys.argv:
26+
# print(i)
27+
# print(sys.path)
28+
29+
# from sys import argv,path
30+
#
31+
# print(path)
32+
33+
help(print)

com/lxl/base/Python2_ShuJuLeiXing.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# a=100
2+
# b=100.0
3+
# c='ddd'
4+
# a,b,c=1,2,'test'
5+
# print(a)
6+
# print(b)
7+
# print(c)
8+
9+
# Python3 中有六个标准的数据类型:
10+
11+
# Number(数字)数字分类别
12+
# String(字符串)
13+
# List(列表)
14+
# Tuple(元组)
15+
# Set(集合)
16+
# Dictionary(字典)
17+
18+
# 不可变数据(3 个):Number(数字)、String(字符串)、Tuple(元组);
19+
# 可变数据(3 个):List(列表)、Dictionary(字典)、Set(集合)。
20+
a,b,c,d=1,1.2,True,4+4j
21+
22+
# print(type(a))
23+
# print(type(b))
24+
# print(type(c))
25+
# print(type(d))
26+
#
27+
# print(isinstance(a,bool))
28+
29+
30+
print(b**3)
31+
32+
print(3/2)
33+
print(3//2)
34+
35+
print(1+0.1)
36+
37+
# 字符串不可变
38+
# 元组不可变
39+

com/lxl/base/Python3_DieDaiQi.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
list=[1,2,3,'e',3,3,4]
2+
3+
# it= iter(list)
4+
# for i in it:
5+
# print(i)
6+
7+

com/lxl/base/Python4_ShuJuJieGou.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# list1=[1,2,3,4]
2+
# list1.append(4)
3+
#
4+
# list1.insert(1,3)
5+
#
6+
# list1.sort()
7+
#
8+
# print(list1)
9+
#
10+
# list1.reverse()
11+
# list1.append(5)
12+
# list1.append(6)
13+
# a= list1.pop()
14+
# print(a)
15+
# print(list1)
16+
17+
# stack=[3,4,5]
18+
# stack.append(7)
19+
# print(stack)
20+
#
21+
# stack.pop()
22+
# print(stack)
23+
#
24+
# stack.pop()
25+
# print(stack)
26+
27+
28+
# from collections import deque
29+
#
30+
# queue=(['bruce','jackey','mouth'])
31+
# queue.append('lily')
32+
# print(queue)
33+
#
34+
# queue.popleft()
35+
36+
37+
# tmp1=[1,2,3]
38+
# # tmp1_a=[ 3*x for x in tmp1]
39+
# tmp1_a=[ [x,3*x] for x in tmp1]
40+
# print(tmp1)
41+
# print(tmp1_a)
42+
43+
44+
# tmp2=[" you "," are "," a big man","!"]
45+
46+
# tmp2_a=[ x.strip() for x in tmp2 if len(x)>5]
47+
#
48+
# print(tmp2)
49+
# print(tmp2_a)
50+
51+
52+
53+
str=input("请输入:")
54+
print(str)
55+
56+
57+

com/lxl/base/Python5_File.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
open("C:\\1.txt")

com/lxl/base/Python6_StandardAPI.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import os
2+
3+
# a=os.getcwd()
4+
# print(a)
5+
#
6+
# os.chdir("D:\\")
7+
# a=os.getcwd()
8+
# print(a)
9+
# a1= os.system("mkdir today")
10+
# dir(os)
11+
12+
13+
import shutil
14+
15+
# shutil.copyfile("C:\\1.txt","D:\\11111.txt")
16+
# import glob
17+
# os.chdir("C:\\")
18+
# b=glob.glob("*.txt")
19+
# print(b)
20+
21+
22+
23+
24+
25+
import math
26+
# a=math.cos(math.pi/4)
27+
# print(a)
28+
29+
import random
30+
31+
# a=random.choice(['a','b','c'])
32+
# print(a)
33+
34+
# from datetime import date
35+
# print(date.today())
36+
37+
import zlib
38+
39+
s=b'witch which hasssssss which witches wrist watch'
40+
print(len(s))
41+
t=zlib.compress(s)
42+
print(len(t))
43+
44+
45+
46+
47+
48+
49+
50+
51+
52+
53+
54+
55+
56+
57+
print("OK!")
58+

com/lxl/higer/Python1_ZhengZe.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import re
2+
3+
print(re.match("www","www.baidu.com").span())
4+
# print(re.match("www","www.baidu.com"))
5+
6+
print(re.search("www","www.baidu.com"))

com/lxl/higer/Python2_MySql.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import mysql.connector
2+
3+
mydb = mysql.connector.connect(
4+
host="localhost", # 数据库主机地址
5+
user="root", # 数据库用户名
6+
passwd="123456" # 数据库密码
7+
)
8+
9+
# print(mydb)
10+
11+
mycusor= mydb.cursor()
12+
# mycusor.execute('create database python_test')
13+
14+
15+
mycusor.execute('show databases')
16+
17+
for x in mycusor:
18+
print(x)
19+
20+
print("OK!")

com/lxl/higer/Python3_PyMySql.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
# 更好用的库,连接mysql
3+
4+
import pymysql
5+
6+
# 打开数据库连接
7+
db = pymysql.connect("localhost", "root", "123456", "test1")
8+
9+
# 使用 cursor() 方法创建一个游标对象 cursor
10+
cursor = db.cursor()
11+
12+
# 使用 execute() 方法执行 SQL 查询
13+
cursor.execute("SELECT VERSION()")
14+
15+
# 使用 fetchone() 方法获取单条数据.
16+
data = cursor.fetchone()
17+
18+
print("Database version : %s " % data)
19+
20+
# 关闭数据库连接
21+
db.close()

com/lxl/higer/Python4_Socket.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# 导入 socket、sys 模块
2+
import socket
3+
import sys
4+
5+
# 创建 socket 对象
6+
serversocket = socket.socket(
7+
socket.AF_INET, socket.SOCK_STREAM)
8+
9+
# 获取本地主机名
10+
host = socket.gethostname()
11+
12+
port = 9999
13+
14+
# 绑定端口号
15+
serversocket.bind((host, port))
16+
17+
# 设置最大连接数,超过后排队
18+
serversocket.listen(5)
19+
20+
while True:
21+
# 建立客户端连接
22+
clientsocket, addr = serversocket.accept()
23+
24+
print("连接地址: %s" % str(addr))
25+
26+
msg = '欢迎访问!' + "\r\n"
27+
clientsocket.send(msg.encode('utf-8'))
28+
clientsocket.close()

0 commit comments

Comments
 (0)