_io.TextIOWrapper
'''
SELECT * FROM Info_Roles WHERE Flag=1 LIMIT 2; select top y * from 表 where 主键 not in(select top (x-1)*y 主键 from 表) 如果表中无主键,可以用临时表,加标识字段解决.这里的x,y可以用变量. select id=identity(int,1,1),* into #tb from 表
select * from #tb where id between (x-1)*y and x*y-1 select top 1000 Info_ID from Info_Roles
select top 2000 Info_ID,',xiaole20180410SPLIT,',content from Info_Content where Info_ID not in( select top 1000 Info_ID from Info_Roles ) ;
select top 399 Info_ID,',xiaole20180410SPLIT,',UPPER(content) from Info_Content ;
select top 399 CHARINDEX('IMG',UPPER(content)) from Info_Content ;
select top 15 Info_ID,',xiaole20180410SPLIT,',content from Info_Content where CHARINDEX('IMG',UPPER(content))>0;
select top 15 Info_ID,',xiaole20180410SPLIT,',content from Info_Content where
Info_ID in( select top 1000 Info_ID from Info_Roles ) and
CHARINDEX('IMG',UPPER(content))>0
; SELECT
TOP 15 Info_ID,
',xiaole20180410SPLIT,',
content
FROM
Info_Content
WHERE
Info_ID IN (
SELECT
TOP 1000 Info_ID
FROM
Info_Roles
WHERE
Flag = 1
)
AND CHARINDEX('IMG', UPPER(content)) > 0; SELECT
TOP 200 Info_ID,
',xiaole20180410SPLIT,',
content
FROM
Info_Content
WHERE
Info_ID IN (
SELECT
TOP 90000 Info_ID
FROM
Info_Roles
)
AND CHARINDEX('<IMG', UPPER(content)) > 0; ''' from bs4 import BeautifulSoup
from selenium import webdriver xlsplit_str = ',xiaole20180410SPLIT,'
xlsplit_str = ',xiaole20180410SPLIT,'
f_db_txt, uid_d = 'db.uid.para.txt', {}
f_db_txt, uid_d = 'db.uid.para.byhand.txt', {}
uid_ = 0
# uid = '{}{}'.format('byhand', uid_)
# uid_d[uid]={}
with open(f_db_txt, 'r', encoding='utf-8') as fr:
for i in fr:
i = i.replace('\t', '').replace('\n', '')
if xlsplit_str in i:
l = i.split(xlsplit_str)
# uid = l[0].replace(' ', '')
# uid = l[0].replace(' ', '')
uid_ += 1
uid = '{}{}'.format('byhand', uid_)
uid_d[uid] = {}
# uid_d[uid]['html'] = []
# uid_d[uid]['html'].append(l[1])
uid_d[uid]['html'] = l[1]
else:
# uid_d[uid]['html'].append(i)
uid_d[uid]['html'] = '{}{}'.format(uid_d[uid]['html'], i) r_d = {} '''
中文分句
'''
cutlist = ['。', ';', '?', '.', ';', '?', '...', '、、、', ':', ':', ',', ','] # 检查某字符是否分句标志符号的函数;如果是,返回True,否则返回False
def FindToken(cutlist, char):
if char in cutlist:
return True
else:
return False # 进行分句的核心函数
def Cut(cutlist, lines): # 参数1:引用分句标志符;参数2:被分句的文本,为一行中文字符
l = [] # 句子列表,用于存储单个分句成功后的整句内容,为函数的返回值
line = [] # 临时列表,用于存储捕获到分句标志符之前的每个字符,一旦发现分句符号后,就会将其内容全部赋给l,然后就会被清空 for i in lines: # 对函数参数2中的每一字符逐个进行检查 (本函数中,如果将if和else对换一下位置,会更好懂)
if FindToken(cutlist, i): # 如果当前字符是分句符号
line.append(i) # 将此字符放入临时列表中
l.append(''.join(line)) # 并把当前临时列表的内容加入到句子列表中
line = [] # 将符号列表清空,以便下次分句使用
else: # 如果当前字符不是分句符号,则将该字符直接放入临时列表中
line.append(i)
return l ''' ''' def paragraph_to_sentence(paragraph, sentence_l):
paragraph = paragraph.replace(' ', '')
sentence_split_l = ['\n', '\t', '。', ';', '?', '.', ';', '?', '...', '、、、', ',', ',']
for i in sentence_split_l:
ll = paragraph.split(i)
sentence_l.append(ll[0])
if len(ll) > 1:
paragraph_to_sentence(ll[1], sentence_l)
else:
break return sentence_l def paragraph_to_sentence_no_recursion(paragraph, sentence_l):
paragraph = paragraph.replace(' ', '')
sentence_split_l = ['\n', '\t', '。', ';', '?', '.', ';', '?', '...', '、、、', ',', ',']
for i in sentence_split_l:
ll = paragraph.split(i)
sentence_l.append(ll[0])
if len(ll) > 1:
paragraph_to_sentence(ll[1], sentence_l)
else:
break return sentence_l paragraph = ''
sentence_l = []
paragraph = paragraph.replace(' ', '')
sentence_split_l = ['\n', '\t', '。', ';', '?', '.', ';', '?', '...', '、、、', ',', ',']
for i in sentence_split_l:
ll = paragraph.split(i)
sentence_l.append(ll[0])
if len(ll) > 1:
paragraph_to_sentence(ll[1], sentence_l)
else:
break def sentence_l_to_sentence_l_l(sentence_l):
sentence_l_l = []
sentence_split_l = ['\n', '\t', '。', ';', '?', '.', ';', '?', '...', '、、、', ',', ',']
for i in sentence_l:
for ii in sentence_split_l:
ll = i.split(ii)
if len(ll) > 1:
sentence_l_l += ll
else:
sentence_l_l.append(i)
continue return sentence_l_l import requests, time, threading img_dir = 'C:\\Users\\sas\\PycharmProjects\\py_win_to_unix\\crontab_chk_url\\personas\\trunk\\plugins\\spider\\dl_img_tmp\\'
img_dir = 'C:\\Users\\sas\\PycharmProjects\\produce_video\\mypng\\'
import random import os, time, glob os_sep = os.sep
this_file_abspath = os.path.abspath(__file__)
this_file_dirname, this_file_name = os.path.dirname(this_file_abspath), os.path.abspath(__file__).split(os_sep)[
-1]
fw_f = '{}{}'.format(this_file_name, '.txt')
fw_f_onerow = '{}{}'.format(fw_f.replace( '.txt',''), '.txt') with open(fw_f, 'w', encoding='utf-8') as fw_txt:
with open(fw_f_onerow, 'w', encoding='utf-8') as fw_txt_onerow:
for uid in uid_d:
str_ = uid_d[uid]['html']
fhtml = 'qqzong.vedio.allinone.tmp.html'
fhtml = '{}{}{}{}'.format('D:\\myv\\myhtml\\', int(time.time()), random.randint(1234, 6789), fhtml)
with open(fhtml, 'w', encoding='utf-8') as fw:
fw.write(str_)
with open(fhtml, 'r', encoding='utf-8') as fo:
soup = BeautifulSoup(fo, 'html.parser')
sentence_l = Cut(list(cutlist), list(soup.text)) # 过滤句子单条长度 条数
sen_num = 32
sen_pass = False
if len(sentence_l) < sen_num:
sen_pass = True
continue for sen in sentence_l:
if len(sen) > 64:
sen_pass = True
break
if sen_pass:
continue
s = '{}{}{}'.format('-----------------------', uid, '----------------------------------------\n')
fw_txt.write(s)
fw_txt_onerow(s)
n = 0
for sen in sentence_l:
s = '{}{}'.format(sen, '\n')
print(s)
fw_txt.write(s)
n += 1
if n == 31:
break
# 联系方式:王经理13212312312
fw_txt_onerow(''.join(sentence_l[0:31]))
s = '{}{}{}'.format('联系方式:王经理', random.randint(13200000000, 15812341234), '\n')
fw_txt.write(s)
fw_txt_onerow(s) dd = 9
_io.TextIOWrapper的更多相关文章
- TypeError: '_io.TextIOWrapper' object does not support item assignment
纯小白 遇到的细节问题: 报错 一开始看到这个傻逼了 TypeError: '_io.TextIOWrapper' object does not support item assignment 其实 ...
- 在使用HTMLTestRunner时,报告为空,错误提示<_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf_8'>
<_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf_8'> Time Elapsed: 0:00:21.3163 ...
- python-open文件处理
python内置函数open()用于打开文件和创建文件对象 语法 open(name[,mode[,bufsize]]) name:文件名 mode:指定文件的打开模式 r:只读 w:写入 a:附加 ...
- python基础-面向对象进阶
一.什么是反射 反射的概念是由Smith在1982年首次提出的,主要是指程序可以访问.检测和修改它本身状态或行为的一种能力(自省).这一概念的提出很快引发了计算机科学领域关于应用反射性的研究.它首先被 ...
- python读取文件的方法
一. 通过readline 逐行读取: #--encoding:utf-8 with open("ha.conf","r",encoding='utf-8') ...
- python基础-文件操作
一.文件操作 打开文件时,需要指定文件路径和以何等方式打开文件,打开后,即可获取该文件句柄,日后通过此文件句柄对该文件操作. 打开文件的模式有: r ,只读模式[默认模式,文件必须存在,不存在则抛出异 ...
- python基础-迭代器和生成器
一.递归和迭代 1.递归:(问路示例) 递归算法是一种直接或者间接地调用自身算法的过程.在计算机编写程序中,递归算法对解决一大类问题是十分有效的,它往往使算法的描述简洁而且易于理解. 2.迭代:简单理 ...
- python3中用HTMLTestRunner.py报ImportError: No module named 'StringIO'如何解决
python3中用HTMLTestRunner.py报ImportError: No module named 'StringIO'的解决方法: 1.原因是官网的是python2语法写的,看官手动把官 ...
- Python之路【第十九章】:Django进阶
Django路由规则 1.基于正则的URL 在templates目录下创建index.html.detail.html文件 <!DOCTYPE html> <html lang=&q ...
随机推荐
- Squid 正向代理
实现通过特定设备对特定的网址访问加速 使用squid 正向代理 实现,区别于反向代理,两者区别的根本在于作为中转的服务器在一个完整的请求中是代表客户端还是代表服务器. 服务端设置 1.安装程序包(推荐 ...
- Spring 中无处不在的 Properties
转自:https://javadoop.com/post/spring-properties?hmsr=toutiao.io&utm_medium=toutiao.io&utm_sou ...
- 十二届 - CSU 1803 :2016(同余定理)
题目地址:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1803 Knowledge Point: 同余定理:两个整数a.b,若它们除以整数m所 ...
- Nginx+Tomcat简单负载均衡
Nginx,Apache安装完成 复制Tomcat: tomcat-8080 tomcat-8081 启动Tomcat8080: cd /usr/local/tomcat-8080/bin ...
- Linux无人值守安装系统
yum install dhcp -yvim /etc/dhcp/dhcpd.conf--------------------------------------------- allow booti ...
- php正则表达式匹配html标签
用php正则表达式找出div标签,div允许多层嵌套,比如在以下文本中找出class为quizPutTag的div? <html> <head></head> &l ...
- 使用scrapy 爬取酷狗音乐歌手及歌曲名并存入mongodb中
备注还没来得及写,共爬取八千多的歌手,每名歌手平均三十首歌曲算,大概二十多万首歌曲 run.py #!/usr/bin/env python # -*- coding: utf-8 -*- __aut ...
- 洛谷 2048 BZOJ 2006 [NOI2010]超级钢琴
[题解] 贪心题.设五元组(mx,pos,l,r1,r2)表示最大值为mx,取得最大值的区间右端点为pos,区间左端点为l,区间右端点的可选区间为[r1,r2]. 每次从堆里拎出最大值,然后把这个区间 ...
- C语言基础--数据
c语言中数据: 在8位单片机种最常用的数据类型就是: unsigned char: 无符号字符型,位宽1个字节,8个位,表示的范围0~255(2^8-1) 在32位单片机中最常用的数据类型就是: un ...
- Eclipse中使用JRebel实现项目热部署(Maven插件版)
JRebel实现项目热部署(Maven插件版) 热部署,就是在应用运行过程中不进行重启,可直接进行软件升级. 在开发过程中,热部署就是在项目运行过程中变更代码,无需重启服务器即可使代码生效. tomc ...