随笔分类 -  python|运维

摘要:实现学生注册功能,效果图如下 访问 http://127.0.0.1:8000/student/ 流程 1. 新建工程 test27 2. 新建应用 stu python manage.py startapp stu 3. settings.py 新增加 INSTALLED_APPS stu 修改链 阅读全文
posted @ 2020-12-07 14:49 lixinliang 阅读(324) 评论(0) 推荐(0)
摘要:原生分页 环境: 1.已将抓取的影视内容存放至mysql 数据库中 2.Django 配置mysql 数据库,并且能够正常运行 需求: 1.访问 http://127.0.0.1:8000/movie/ 显示影片内容,每页要求显示20条内容 2.页面底部增加 上一页、下一页功能 过程: 1. 新建立 阅读全文
posted @ 2020-12-02 18:51 lixinliang 阅读(461) 评论(0) 推荐(0)
摘要:Django 注册、展示、登陆功能 ###环境: pycharm 201902 Python 2.7.13 Django 1.11.6 ###一、注册: 1. 新创建 project File->NewProject->Django->选择项目存放路径,命名 test18 ->下拉 -> 选择 Ex 阅读全文
posted @ 2020-12-01 10:34 lixinliang 阅读(267) 评论(0) 推荐(0)
摘要:1. 删除该app名字下的migrations文件。 2. 进入数据库,找到django_migrations的表,删除该app名字的所有记录。 3. python manage.py makemigrations 4. python manage.py migrate 5. python mana 阅读全文
posted @ 2020-11-25 11:36 lixinliang 阅读(243) 评论(1) 推荐(1)
摘要:class Person(): def __init__(self,name,age,weight): self.name = name self.age = age self.weight = weight def talk(self): print("%s is talking I am %d 阅读全文
posted @ 2020-11-12 14:39 lixinliang 阅读(165) 评论(0) 推荐(0)
摘要:$ cat checkdisk.py #!/usr/bin/python # -*- coding: utf-8 -*- import os import socket import smtplib from email.mime.text import MIMEText from email.he 阅读全文
posted @ 2020-11-04 15:13 lixinliang 阅读(301) 评论(0) 推荐(0)
摘要:$ cat checkserver.py #!/usr/bin/python # -*- coding: utf-8 -*- import os import socket import smtplib from email.mime.text import MIMEText from email. 阅读全文
posted @ 2020-10-16 11:28 lixinliang 阅读(194) 评论(0) 推荐(0)
摘要:使用 pip 命令来安装 mysql-connector: python -m pip install mysql-connector 开始演练: import mysql.connector mydb = mysql.connector.connect( host="192.168.10.10", 阅读全文
posted @ 2020-10-14 17:02 lixinliang 阅读(357) 评论(0) 推荐(0)
摘要:#父类Person class Person(): def __init__(self,name,age,hair): self.name = name self.age = age self.hair = hair def talk(self): print("Person is talking 阅读全文
posted @ 2020-10-13 19:20 lixinliang 阅读(892) 评论(0) 推荐(0)
摘要:class Person: #类名称 a = 0 #初始化一个起始值 def __init__(self,name,height,weight): #类的初始化,第一个参数必须是 self,后面参数分别表示为 名称,身高,体重 self.name = name #访问对应的变量 self.heigh 阅读全文
posted @ 2020-10-13 17:17 lixinliang 阅读(244) 评论(0) 推荐(0)
摘要:import requests from pyquery import PyQuery as pq import time import os import random #自定义header header = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10. 阅读全文
posted @ 2020-10-10 23:05 lixinliang 阅读(132) 评论(0) 推荐(0)
摘要:[root@linag python]# vim config.py import configparser config = configparser.ConfigParser() config["DEFAULT"] = {'ServerAliveInterval': '45', 'Compression': 'yes', ... 阅读全文
posted @ 2018-03-10 11:38 lixinliang 阅读(286) 评论(0) 推荐(0)
摘要:随机形成字母和数字组成的五位字符码。 [root@localhost python]# vim timee.py import random def coder(): code = '' for i in range(5): add = random.choice([random.randrange(10),chr(random.randrange(65,91))]) ... 阅读全文
posted @ 2018-02-04 17:43 lixinliang 阅读(164) 评论(0) 推荐(0)
摘要:python 中生成器都是迭代器,而迭代器不一定是生成器。 迭代器: 满足以下两个条件 1,有inter方法 2,有next方法 阅读全文
posted @ 2018-02-04 15:56 lixinliang 阅读(133) 评论(0) 推荐(0)
摘要:python 生成器一共两种创建方法: 1,(x for x in range(5)) 2,yield 例如: # vim 3.py def fib(max): n,before,after = 0,0,1 while n < max: yield before before,after = aft 阅读全文
posted @ 2018-02-04 12:42 lixinliang 阅读(162) 评论(0) 推荐(0)
摘要:四,闭包: 阅读全文
posted @ 2018-02-03 14:36 lixinliang 阅读(210) 评论(0) 推荐(0)
摘要:浅拷贝只是拷贝第一层,深拷贝相当于克隆,深拷贝如下: 阅读全文
posted @ 2018-01-28 12:38 lixinliang 阅读(164) 评论(0) 推荐(0)
摘要:1, 使用文件 #vim /etc/motd "1 hello world" 2 ...... yes 3 no you are a shadiao 4 hahh maye you are right ddddddddddddddddddddddddddddddddddd ccccccccccccc vvv 1 2,python脚本 2 [root@localho... 阅读全文
posted @ 2018-01-19 12:01 lixinliang 阅读(3210) 评论(0) 推荐(0)
摘要:1,要求在文件 2.py 第六行插入一句话; 1 #cat /root/python/2.py 2 昨夜雨疏风骤1 3 昨夜雨疏风骤2 4 昨夜雨疏风骤3 5 昨夜雨疏风骤4 6 昨夜雨疏风骤5 7 昨夜雨疏风骤6 8 昨夜雨疏风骤7 1 # vim /root/python/file.py 2 f = open("/root/python/2.py","r") 3 num ... 阅读全文
posted @ 2018-01-15 22:15 lixinliang 阅读(208) 评论(0) 推荐(0)
摘要:1 #!coding: utf-8 2 s = "特斯拉" 3 s_to_unicode = s.decode("utf-8") 4 unicode_to_gbk = s_to_unicode.encode("gbk") 5 print s 6 print ("unicode:", s_to_unicode) 7 print ("gbk", unicode_to_gbk) 8 ... 阅读全文
posted @ 2018-01-15 14:46 lixinliang 阅读(429) 评论(0) 推荐(0)