
Python3爬坑之路
文章平均质量分 66
-天道酬勤-
有志者、事竟成,破釜沉舟,百二秦关终属楚; 苦心人、天不负,卧薪尝胆,三千越甲可吞吴。
展开
-
Windows中python3使用minio
【代码】Windows中python3使用minio。原创 2024-11-29 17:47:04 · 309 阅读 · 0 评论 -
python3中虚拟环境virtualenv、virtualenvwerapper-win
上面创建的环境在C:\Users\THINKPAD\Envs文件夹。关闭dos窗口,重新打开,然后使用上面命令,环境就在配置的文件中了。查看virtualenvwerapper-win版本。修改配置 决定创建的环境在那个文件夹(修改环境变量)查看virtualenv版本。退出 deactivate。退出 deactivate。创建虚拟环境并且会进入。原创 2024-08-23 16:32:29 · 733 阅读 · 0 评论 -
(二十四)Python 发送邮件html格式附件以及图片
import smtplibfrom email.mime.text import MIMETextfrom email.mime.multipart import MIMEMultipartfrom email.utils import formataddrmy_sender = '***********@163.com' # 发件人邮箱账号my_pass = '*********...原创 2019-12-05 15:53:23 · 1272 阅读 · 0 评论 -
(二十三)Python MongoDB学习
安装驱动pip install pymongo添加数据import pymongomyClient = pymongo.MongoClient("mongodb://localhost:27017/")dbList = myClient.list_database_names()print(dbList)if 'school' in dbList: print('数据库已...原创 2019-12-05 11:23:58 · 753 阅读 · 0 评论 -
(二十二)Python 时间日期练习
# 日期时间import timeimport calendarticks = time.time()print('当前时间戳:%s' % ticks)localtime = time.localtime(time.time())print("本地时间为 :", localtime)# 获取格式化的时间localtime = time.asctime(time.localti...原创 2019-12-05 09:14:21 · 990 阅读 · 0 评论 -
(二十一)Python Json练习
import jsondata = { 'no': 1, 'name': 'WangFan', 'url': 'http://www.WangFan.com'}json_str = json.dumps(data)print("Python 原始数据:", repr(data))print("JSON 对象:", json_str)data1 = { ...原创 2019-12-05 09:13:47 · 1116 阅读 · 0 评论 -
(二十)Python 解析xml练习
import xml.dom.minidom# 使用minidom解析器打开 XML 文档DOMTree = xml.dom.minidom.parse("movies.xml")collection = DOMTree.documentElementif collection.hasAttribute("shelf"): print("Root element : %s" % ...原创 2019-12-05 09:12:53 · 771 阅读 · 0 评论 -
(十九)Python 多线程小练习
import threadingimport timeexitFlag = 0class myThread (threading.Thread): def __init__(self, threadID, name, counter): threading.Thread.__init__(self) self.threadID = threadI...原创 2019-12-05 09:11:54 · 896 阅读 · 0 评论 -
(十八)Python socket练习
import socket# 创建socket对象serverSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)# 获取本地主机名host = socket.gethostname()port = 999# 绑定主机名端口号serverSocket.bind((host, port))# 设置最大连接数,超过后排队...原创 2019-12-05 09:11:17 · 747 阅读 · 0 评论 -
(十七)Python数据库练习
import pymysql# 安装pip install PyMySQL# 打开数据库连接db = pymysql.connect("localhost", "root", "root", "python_test")# 使用cursor()方法创建一游标对象cursorcursor = db.cursor()# 使用execute()方法执行SQL查询cursor.execut...原创 2019-12-05 09:10:11 · 809 阅读 · 0 评论 -
(十六)Python正则匹配练习
import re# re.match 尝试从字符串的起始位置匹配一个模式,如果不是起始位置匹配成功的话,match()就返回none。print(re.match('www', 'www.wangFan.com').span())print(re.match('com', 'www.wangFan.com'))line = "Cats are smarter than dogs"#...原创 2019-12-05 09:09:08 · 808 阅读 · 0 评论 -
(十五)Python面向对象练习
class People: name = '' age = 0 __weight = 0 def __init__(self, n, a, w): self.name = n self.age = a self.__weight = w def speak(self): print("%s ...原创 2019-12-04 17:51:42 · 1040 阅读 · 0 评论 -
(十四)Python系统OS和import练习
#!/usr/bin/python3import osres = os.access('0015.py', os.F_OK)print(res)res = os.access('0015.py', os.R_OK)print(res)res = os.access('0015.py', os.W_OK)print(res)res = os.access('0015.py...原创 2019-12-04 17:50:41 · 725 阅读 · 0 评论 -
(十三)Python文件练习
# 读写文件# 打开一个文件f = open("foo.txt", "w")f.write("Python 是一个非常好的语言。\n是的,的确非常好!!\n")# 关闭打开的文件f.close()# 打开一个文件f = open("foo.txt", "r")strLine = f.readline()print(strLine)# 关闭打开的文件f.close()#...原创 2019-12-04 17:49:35 · 757 阅读 · 0 评论 -
(十二)Python函数练习
# 函数# 定义函数def print_me(test): # 打印任何传入的字符串 print(test)# 调用函数print_me("我要调用用户自定义函数!")print_me("再次调用同一函数")# 不定长参数# 加了星号 * 的参数会以元组(tuple)的形式导入def print_info(arg1, *var_tuple): p...原创 2019-12-04 17:48:52 · 695 阅读 · 0 评论 -
(十一)Python迭代器生成器练习
# 迭代器与生成器# iter() 和 next()listTest = [1, 2, 3]listTest = iter(listTest)print(next(listTest))print(next(listTest))print(next(listTest))listTest = [1, 2, 3]listTest = iter(listTest)for x in l...原创 2019-12-04 17:48:04 · 925 阅读 · 0 评论 -
(十)Python条件判断练习
# 条件控制# 斐波拉数列a, b = 0, 1while b < 10: print(b, end=' ') a, b = b, a+bprint()var1 = 100if var1: print("1 - if 表达式条件为 true") print(var1)var2 = 0if var2: print("2 - if 表...原创 2019-12-04 17:47:21 · 1047 阅读 · 0 评论 -
(九)Python集合类型练习
# 集合# 可以使用大括号 { } 或者 set() 函数创建集合# 创建空集合set()不能使用{},{}是创建空字典# 去重功能basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}print(basket)basket.add('苹果')print(basket)basket.update([11,...原创 2019-12-04 17:45:30 · 1018 阅读 · 0 评论 -
(八)Python字典类型练习
# 字典dict1 = {'Alice': '2341', 'Beth': '9102', 'Cecil': '3258'}dict2 = {'abc': 456}dict3 = {'abc': 456, 'def': 789}print(dict1)print(dict2)print(dict3)print(dict1['Alice'])print(dict1['Cecil'...原创 2019-12-04 17:44:52 · 756 阅读 · 0 评论 -
(七)Python元祖类型练习
# 元祖tup1 = ('Google', 'Runoob', 1997, 2000);tup2 = (1, 2, 3, 4, 5)# 不需要括号也可以tup3 = "a", "b", "c", "d"print(type(tup3))# 创建空元祖tup4 = ()print(tup4)print(type((10)))print(type((10, )))# 元祖值不...原创 2019-12-04 17:44:19 · 979 阅读 · 0 评论 -
(六)Python列表类型练习
# 列表list1 = ['Google', 'Runoob', 1997, 2000]list2 = [1, 2, 3, 4, 5]list3 = ["a", "b", "c", "d"]print(list1[0])print(list1[1:5])print(list2)list2[2] = 20print(list2)del list2[2]print(list...原创 2019-12-04 17:43:47 · 837 阅读 · 0 评论 -
(五)Python字符串类型练习
# 字符串var1 = 'Hello Word'var2 = 'Runoob'print(var1[0])print(var2[1:5])print(var1[:6] + var2)a = "Hello"b = "Python"print("a + b 输出结果:", a + b)print("a * 2 输出结果:", a * 2)print("a[1] 输出结果:...原创 2019-12-04 17:43:18 · 772 阅读 · 0 评论 -
(四)Python数字类型练习
# 数字Numberimport mathimport randomvar1 = 1var2 = 10number = 0xA0Fprint(number)number = 0o37print(number)number = 5print(number ** 2)# 求绝对值print(abs(-5))# 向上取整print(math.ceil(4.1))...原创 2019-12-04 17:42:39 · 888 阅读 · 0 评论 -
(三)Python基本数据类型练习
# 基本数据类型counter = 100miles = 1000.00name = 'WangFan'print(counter, miles, name)a = b = c = 1print(a, b, c)a, b, c = 1, 2, 'WangFan'print(a, b, c)"""不可变数据 Number 数字 String 字符串...原创 2019-12-03 15:40:43 · 926 阅读 · 0 评论 -
(二)Python基础语法练习
# 基础语法import sysstrHelloPython = "Hello Python"print(strHelloPython)if True: print('true')else: print('false')itemOne = 1itemTwo = 2itemThree = 3total = itemOne + \ itemT...原创 2019-12-03 15:38:56 · 763 阅读 · 0 评论 -
(一)Python安装
Python爬坑之路之安装安装虚拟机以及UbuntuUbuntu官网地址查看python版本python3 -VUbuntu切换root用户sudo su安装pip3apt install python3-pip查看安装的pip3版本pip3 -V...原创 2019-04-26 14:17:29 · 181 阅读 · 0 评论