V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  jookr  ›  全部回复第 62 页 / 共 62 页
回复总数  1231
1 ... 53  54  55  56  57  58  59  60  61  62  
2014-12-24 18:23:34 +08:00
回复了 jookr 创建的主题 Python 求助 入门级简单地操作数据库的小问题
@liprais 报错信息如下

Traceback (most recent call last):
File "E:\python\tt.py", line 21, in <module>
cursor.execute(query);
File "D:\Python27\lib\site-packages\MySQLdb\cursors.py", line 202, in execute
self.errorhandler(self, exc, value)
File "D:\Python27\lib\site-packages\MySQLdb\connections.py", line 36, in defau
lterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.ProgrammingError: (2014, "Commands out of sync; you can't run
this command now")
2014-12-16 19:50:52 +08:00
回复了 xiaowangge 创建的主题 Python Python 练习册,每天一个小程序 :-)
自己解决了


# -*- coding: utf-8 -*-


import re
html = 'www啊啊啊,呵呵,哈哈,嘿嘿'
#counts = re.findall(r'"www(.*),呵呵,哈哈,嘿嘿', html)
counts = re.findall(r'www(.*?),(.*?),(.*?),', html)
get_content = counts[0]

#print get_content

for i in get_content:
print i.decode('utf-8').encode('cp936')
2014-12-16 19:40:30 +08:00
回复了 xiaowangge 创建的主题 Python Python 练习册,每天一个小程序 :-)
@realityone 谢谢
但是你的代码会获取整个www后面的内容,不能只截取出"啊啊啊"

import re
html = 'www啊啊啊,呵呵,哈哈,嘿嘿'
#counts = re.findall(r'"www(.*),呵呵,哈哈,嘿嘿', html)
counts = re.findall(r'www(.*)', html)
get_content = counts[0]

print get_content.decode('utf-8').encode('cp936')
2014-12-16 19:30:35 +08:00
回复了 xiaowangge 创建的主题 Python Python 练习册,每天一个小程序 :-)
中文的逗号匹配结尾会提示错误怎么办
2014-12-16 19:14:29 +08:00
回复了 xiaowangge 创建的主题 Python Python 练习册,每天一个小程序 :-)
大神 能否指点一下,我昨天刚入门
正则截取内容不会
下面这个例子 我需要截取"啊啊啊"这个内容出来怎么获取不到呢

import re
html = 'www啊啊啊,呵呵,哈哈,嘿嘿'
counts = re.findall(r'"www(.*),呵呵,哈哈,嘿嘿', html)

print counts[1]

raw_input()
2014-12-09 09:06:44 +08:00
回复了 langqianyi 创建的主题 问与答 晚上磨牙怎么办?没有根治的办法吗?
你试试侧着睡
2014-12-08 14:18:03 +08:00
回复了 princeofwales 创建的主题 香港 求推荐一间满意又便宜的香港酒店
穷游香港
晚上不住店
能在哪里混时间?
非主流后缀都不让备案就悲剧了
2014-12-02 18:47:34 +08:00
回复了 juqkai 创建的主题 问与答 求用->=|画流程图的网站
2014-10-26 14:57:03 +08:00
回复了 hopestar86 创建的主题 PHP 请教,怎么样能有效的屏蔽小偷程序?
获取IP只需要一句话,$_SERVER["REMOTE_ADDR"]这就足够了,没必要也不应该获取代理IP地址,REMOTE_ADDR是服务器和客户端握手后建立的tcp连接的数据帧里的,在应用层是无法修改的。当然,也不是绝对没有办法伪造的,IP协议可以完全自定义传输的数据,路由器这层也能伪造,但对于WEB程序员来说,是底层的东西,无法修改和伪造的。
只有REMOTE_ADDR伪造不了 不用这个还用哪个
1 ... 53  54  55  56  57  58  59  60  61  62  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   4159 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 34ms · UTC 04:13 · PVG 12:13 · LAX 21:13 · JFK 00:13
Developed with CodeLauncher
♥ Do have faith in what you're doing.