• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > python实现mysql的单引号字符串过滤方法

python实现mysql的单引号字符串过滤方法

作者: 字体:[增加 减小] 来源:互联网

通过本文主要向大家介绍了python去掉字符串引号,python 字符串 单引号,python中的三引号,python 单引号 双引号,python 三引号等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

本文实例讲述了python实现mysql的单引号字符串过滤方法。分享给大家供大家参考,具体如下:

最主要用这个函数,可以处理MySQLdb.escape_string(content).

class Guide:
 def __init__(self):
  self.time_zone = 7*3600 #设置时区
  self.now_time = int(time.time()) + self.time_zone #取得当前时间
   #本地
  self.gamedb_model = mysql_conn.MySQLHelper(config.game_db['host'], config.game_db['user'],
    config.game_db['password'], config.game_db['db_name'],
    config.game_db['port'])
  #远程
  self.remote_model = mysql_conn.MySQLHelper(config.remote_db['host'], config.remote_db['user'],
    config.remote_db['password'], config.remote_db['db_name'],
    config.remote_db['port'])
  #game center
  self.commdb_model = mysql_conn.MySQLHelper(config.comm_db['host'], config.comm_db['user'],
   config.comm_db['password'], config.comm_db['db_name'],
   config.comm_db['port'])
 def index(self):
  #拿到第二天未登陆的用户
  for line in open("2014.3.20_global_ips.txt"):
   list = line.split('||')
   l = len(list)
   if l == 3:
    info = ''
   else:
    info = MySQLdb.escape_string(list[3])
   self.commdb_model.insert('ip_area',{'start_ip':list[0],'end_ip':list[1],'area':list[2],'info':info})
if __name__ =="__main__":
 keep = Guide()
 keep.index()

</div>

希望本文所述对大家python程序设计有所帮助。

</div>

您可能想查找下面的文章:

  • python实现mysql的单引号字符串过滤方法

相关文章

  • Python中内置的日志模块logging用法详解
  • Python统计列表中的重复项出现的次数的方法
  • Python中使用Beautiful Soup库的超详细教程
  • 浅谈Python数据类型之间的转换
  • python创建进程fork用法
  • Python中使用platform模块获取系统信息的用法教程
  • Python遍历文件夹和读写文件的实现代码
  • python装饰器decorator介绍
  • Python的Bottle框架中实现最基本的get和post的方法的教程
  • Python中zfill()方法的使用教程

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • 详解Python中的循环语句的用法
    • python有证书的加密解密实现方法
    • 基于Python 的进程管理工具supervisor使用指南
    • Python脚本实现代码行数统计代码分享
    • Python pass 语句使用示例
    • 使用python分析git log日志示例
    • 学习python处理python编码问题
    • python多线程编程方式分析示例详解
    • python使用PyGame绘制图像并保存为图片文件的方法
    • Python基于DES算法加密解密实例

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有