服务器

C:\Users\Administrator\Downloads

D:\Users\Administrator\Anaconda3\Lib\site-packages\synonyms\data

[email protected]

ss19940317

遍历文件夹的方法首先需要调用os库,即

import os

os.walk(path)

path是指想遍历文件夹的路径

而每个tuple中有三项:

1.当前文件夹的路径(str类型)

2.当前文件夹中的所有文件夹名称(list类型)

3.当前文件夹中所有文件的名称,只需要取出i[2]。

mstsc  windows

阿里云香港

47.52.228.218

47.75.35.156

显示选项(o)

本地资源

详细信息(M)

administrator

Ss19940317

linux

root

Ss19940317

linux服务器

数据库

root

Ss1994111!

外部访问

user

sS1994111!

,verify=False

create table jy_comment(id int not null primary key auto_increment ,content varchar(50) not null ,intro varchar(50) not null ,anthor varchar(50) not null ,kiss tinyint(4) not null ,active tinyint(4) default'1' not null ,update_time varchar(50) not null ,add_time varchar(50) not null);

scrapy startproject nipic

cd nipic

scrapy genspider mynipic nipic.com

scrapy genspider -t crawl weisuen sohu.com

显示可用模板  scrapy genspider -l

利用crawlspider创建框架 scrapy genspider -t crawl weisun sohu.com

开始爬取 scrapy crawl weisun --nolog

其实这种情况下scrapy已经安装好了 可以使用 只是有部分功能 有影响就是其中提到的 service_identity模块。其实这个模块是已经安装了的。但是为什么还会报错呢。耗费了我两个小时 各种发帖 搜索。终于在一位大神那里找到了答案

原因是不知道因为什么原因导致本机上的service_identity模块太老旧,而你通过install安装的时候 不会更新到最新版本

通过

pip3 install service_identity --force --upgrade

All_lists = open(All_path, encoding='utf-8').read().strip().replace("\n", "==").split("==")

with open(Gen_path,'a')as file:

    file.write('\n'.join(gen_list)+'\n')


删除第9到14条记录

delete from table_name where id between 9 and 14;

倒序之后删除最前面5条记录

delete from user_ order by id desc limit 5;

正序之后删除最前面5条记录  delete from user_ order by id asc limit 5;delete from records where id in(1,2,3)delete from records where id = 1 or id = 2 or id = 3

#!/usr/bin/python3 import pymysql import types db=pymysql.connect("localhost","root","123456","python"); cursor=db.cursor() #创建user表 cursor.execute("drop table if exists user") sql="""CREATE TABLE IF NOT EXISTS `user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `age` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0""" cursor.execute(sql) #user插入数据 

 sql="""INSERT INTO `user` (`name`, `age`) VALUES ('test1', 1), ('test2', 2), ('test3', 3), ('test4', 4), ('test5', 5), ('test6', 6);""" try: # 执行sql语句 cursor.execute(sql) # 提交到数据库执行 db.commit() except: # 如果发生错误则回滚 db.rollback() #更新 id=1 sql="update user set age=100 where id='%s'" % (id) try: cursor.execute(sql) db.commit() except: db.rollback() #删除 id=2 sql="delete from user where id='%s'" % (id) try: cursor.execute(sql) db.commit() except: db.rollback() #查询 cursor.execute("select * from user") results=cursor.fetchall() for row in results: name=row[0] age=row[1] #print(type(row[1])) #打印变量类型


    print ("name=%s,age=%s" % \ 

            (age, name)) 

你可能感兴趣的:(服务器)