11 2015 档案

MySQLdb-python的安装
摘要:第一步下载: 第一步:进入https://github.com/farcepest/MySQLdb1/ 第二步:解压 Shell>unzip/root/MySQLdb1-MySQLdb-1.3.zip Shell>cd/root/MySQLdb1-MySQLdb-1.3第三步:安装相... 阅读全文

posted @ 2015-11-20 16:50 蒋乐兴的技术随笔 阅读(317) 评论(0) 推荐(0) 编辑

python---__getattr__\__setattr_重载'.'操作
摘要:#!coding:utf-8class Person(object): def __init__(self,id): #定义一个名为ID的属性 self.ID=id def __getattr__(self,attr): #__getattr__... 阅读全文

posted @ 2015-11-13 09:18 蒋乐兴的技术随笔 阅读(387) 评论(0) 推荐(0) 编辑

python----iter\next
摘要:1、说明:__getitem__\setitem可以迭代,它已经不被推荐了;建议使用__iter__\next。2、python会先去检查__iter__\next然后再去检查__getitem__\__setitem__,也就是说__iter__优先。例子:#!coding:utf-8#!pyth... 阅读全文

posted @ 2015-11-12 19:22 蒋乐兴的技术随笔 阅读(458) 评论(0) 推荐(0) 编辑

python--getitme\setitem 支持索引与分片
摘要:1、想要自己定义的python对象支持索引与分片操作就要重载__getitem__\__setitem__这两个方法。2、__getitme__(self,index) 这里的index参数可能类型有两种int,slice。当它是int类型时对应索引操作,当它是slice时对应分片操作。3、__s... 阅读全文

posted @ 2015-11-12 18:24 蒋乐兴的技术随笔 阅读(390) 评论(0) 推荐(0) 编辑

linux----ln
摘要:1、格式 ln source_file_path target_file_path2、执行ln 命令的用户要对source_file_path有写权限,才可以创建软连接。3、souce_file这个文件对ln的执行者要是可达的,也就是说ln的执行者要对source_file的上层目录有x权限。例子:... 阅读全文

posted @ 2015-11-10 17:52 蒋乐兴的技术随笔 阅读(7290) 评论(0) 推荐(0) 编辑

linux----suid\sgid
摘要:1、suid和sgid 都是针对二进制程序来说了,bash脚本不在它的作用范围。2、如果一个二进制文件设置有suid,那么在userA用户执行它时,会以文件所属用户的身份来执行。sgid同理;3、suid的优先级别比sgid的要大,也就是说如果同时设置了这两个话,和只设置suid一样;4、一般说来一... 阅读全文

posted @ 2015-11-10 17:26 蒋乐兴的技术随笔 阅读(329) 评论(0) 推荐(0) 编辑

python生成随机密码
摘要:import randomstrings=list('qwertyuiopasdfghjklzxcvbnm1234567890QWERTYUIOPASDFGHJKLZXCVBNM')random.shuffle(strings)#改变strings内容元素的排列次序print ''.join(ran... 阅读全文

posted @ 2015-11-09 18:23 蒋乐兴的技术随笔 阅读(247) 评论(0) 推荐(0) 编辑

python计算md5值
摘要:from hashlib import md5m = md5('123456')print m.hexdigest() 阅读全文

posted @ 2015-11-09 18:20 蒋乐兴的技术随笔 阅读(166) 评论(0) 推荐(0) 编辑

python---连接MySQL第五页
摘要:Connector/Python Connection ArgumentsA connection with the MySQL server can be established using either the mysql.connector.connect() function or the ... 阅读全文

posted @ 2015-11-05 12:58 蒋乐兴的技术随笔 阅读(811) 评论(0) 推荐(0) 编辑

python---连接MySQL第四页
摘要:python缓存结果集式的cursor可以用来提高性能。例子:#!conding:utf-8from mysql.connector import errorcodeimport mysql.connectorcnx=Nonecursor=Nonetry: cnx = mysql.connec... 阅读全文

posted @ 2015-11-05 12:54 蒋乐兴的技术随笔 阅读(243) 评论(0) 推荐(0) 编辑

python---连接MySQL第三页
摘要:用python语言从MySQL中查询数据#!conding:utf-8from mysql.connector import errorcodeimport mysql.connectorcnx=Nonecursor=Nonetry: cnx = mysql.connector.connect... 阅读全文

posted @ 2015-11-05 12:42 蒋乐兴的技术随笔 阅读(252) 评论(0) 推荐(0) 编辑

python---连接MySQL第二页
摘要:用python向MySQL插入值、并取出被插入行的主键。#!/usr/bin/python#!coding:utf-8import mysql.connectorfrom mysql.connector import errorcodedef insert_data(**kwargs): co... 阅读全文

posted @ 2015-11-05 11:24 蒋乐兴的技术随笔 阅读(238) 评论(0) 推荐(0) 编辑

python----关键字参数
摘要:python以字典作为型参、这样可以做到,在调用函数时可以传入任意多个参数。例子:#!/usr/bin/python#!coding:utf-8def kwFun(**kwargs): #kwargs是一个字典,这样想要多少个型参都可以 if 'host' in kwargs: ... 阅读全文

posted @ 2015-11-05 09:44 蒋乐兴的技术随笔 阅读(178) 评论(0) 推荐(0) 编辑

python---连接MySQL第一页
摘要:前言:python如果想要连接到MySQL要安装上相关的驱动才下;好在驱动程序在mysql的官网可以下载的到。 以下是我自己保存的一个conetos7版本 http://yunpan.cn/cLACS7VurfaE4 访问密码 2e26例子:#!/usr/bin/python#!codi... 阅读全文

posted @ 2015-11-05 08:36 蒋乐兴的技术随笔 阅读(278) 评论(0) 推荐(0) 编辑

python----脚本文件的头部写法。
摘要:#!/usr/bin/python #这里主要是为了指明python脚本解释器的路径。#!coding:utf-8#这个是为了告知python脚本文件解释器,此脚本的字符集。import sys #这下面就可以写模块导入,和别的东西了。 阅读全文

posted @ 2015-11-02 22:26 蒋乐兴的技术随笔 阅读(3259) 评论(0) 推荐(1) 编辑

linux--同步时间
摘要:目标:我们要把192.168.1.202这台主机的时间设置成本机的时间。方法: 1、通过date 命令校正:ssh 192.168.1.202 "date -s\"$(date '+%F %H:%M:%S')\"" 2、通过ntp来校正:在需要校正的机器上运行ntpdate server_ip。 阅读全文

posted @ 2015-11-01 23:22 蒋乐兴的技术随笔 阅读(173) 评论(0) 推荐(0) 编辑

导航

< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8
点击右上角即可分享
微信分享提示