1、HTML注释
<!-- ... -->
注释标签用来在源文档中插入注释//
和/* */
在html里也是常用的注释,但只能用在js和CSS语言,不对HTML语言起作用!
2、python操作sqlite数据的fetchone()、fetchMany()、fetchall()函数
- 使用fetchone()查询一条信息,使用fetchmany(3)查询3条信息,fetchall()查询全部信息
conn = sqlite3.connect('数据库绝对路径/相对路径 + 数据库名')
cursor = con.connection()
cursor.execute("select * from users")
游标cursor
如同C中文件的指针一样,每次都会移动到一定的位置,如果不指定它返回开头,那么就会沿着当前位置继续下一次的移动
3、Python重启项目数据库“被清空”的原因
conn = sqlite3.connect('数据库绝对路径/相对路径 + 数据库名')
conn.commit()
4、python操作sqlite3数据库的流程
import sqlite3
conn = sqlite3.connect("数据库")
cur = conn.cursor()
sql_query = """select * from users where id = 1"""
cur.execute(sql_query)
sql_cmd = """insert into users values(?,?)"""
cur.execute(sql_cmd, (id, user))
conn.commit()
conn.close()
5、python操作sqlite3插入二进制数据
- 二进制数据在sqlite3中存储类型为
BLOB
- 使用占位符来进行插入
import sqlite3
fp = open("box.gif", "rb")
img = fp.read()
conn = sqlite3.connect("test.db")
conn.execute("INSERT INTO image VALUES('m1', ?);", (img,))
conn.commit()
6、sqlite3数据库中的字段类型
- NULL。该值为NULL值。
- INTEGER。该值是有符号整数,存储为1,2,3,4,6或8个字节,具体取决于值的大小。
- REAL。该值是浮点值,存储为8字节IEEE浮点数。
- TEXT。该值是一个文本字符串,使用数据库编码(UTF-8,UTF-16BE或UTF-16LE)存储。
- BLOB。该值是一个数据块,可以二进制的形式存储任何数据。
7、python查看当前路径、判断路径和文件是否存在
>>> os.getcwd()
'C:\\Users\\86130\\AppData\\Local\\Programs\\Python\\Python37'
>>> os.path.abspath('.')
'C:\\Users\\86130\\AppData\\Local\\Programs\\Python\\Python37'
>>> os.path.abspath('..')
'C:\\Users\\86130\\AppData\\Local\\Programs\\Python'
import os
os.path.exists()
import os.path
os.path.if_file('file_name')
from pathlib import Path
my_file = Path('C:\\Users\\86130\\AppData\\Local\\Programs\\Python')
my_file.is_file()
my_file.is_dir()
my_file.exists()