当前位置: 首页 > 编程日记 > 正文

python写一个通讯录step by step V3.0

python写一个通讯录step by step V3.0


更新功能:

数据库进行数据存入和读取操作

字典配合函数调用实现switch功能

其他:函数、字典、模块调用

注意问题:

  • 1、更优美的格式化输出

  • 2、把日期换算成年龄

  • 3、更新操作做的更优雅

准备工作

db准备

  • 创建数据库

    mysql> create database txl charset utf8;
    Query OK, 1 row affected (0.09 sec)mysql>
  • 创建表

    mysql> use txl;
    Database changedmysql> create table tb_txl (id int auto_increment primary key,name char(20),gender char(1),brithday date,tel char(20));
    Query OK, 0 rows affected (0.29 sec)mysql> desc tb_txl;
    +----------+----------+------+-----+---------+----------------+
    | Field    | Type     | Null | Key | Default | Extra          |
    +----------+----------+------+-----+---------+----------------+
    | id       | int(11)  | NO   | PRI | NULL    | auto_increment |
    | name     | char(20) | YES  |     | NULL    |                |
    | gender   | char(1)  | YES  |     | NULL    |                |
    | brithday | date     | YES  |     | NULL    |                |
    | tel      | char(20) | YES  |     | NULL    |                |
    +----------+----------+------+-----+---------+----------------+

开始

1、模板准备

相对于V1、V2、V3版本的,模板基本一致

  • 模板

    #!/usr/bin/env python
    #coding:utf8
    #Author:zhuima
    #Date:2015-03-30
    #Version:0.1
    #Function:display a list and add date# 导入模块
    import osdef menu():'''设置munu目录,提供给用户的操作接口 '''print '''1.add user info2.disp all user info3.update user info by username4:del user by username5:sort user info by 0.exit program'''op = raw_input('Please select one >>> ')return opdef txl_exit():''' 退出程序 '''os._exit(0)def txl_error():''' 当用户输出选项不在定义的选项内的时候,报错'''printprint 'Unkonw options,Please try again!'# 定义dict,配合函数实现switch功能ops = {
    #    '1':txl_add,
    #    '2':txl_dis,
    #    '3':txl_update,
    #    '4':txl_del,
    #    '5':txl_sort,'0':txl_exit,
    }def main():'''主程序 '''while True:op = menu()ops.get(op,txl_error)()if __name__ == '__main__':main()

2、db_config准备

使用db配置单独生产一个配置文件,直接以模块的形式调用即可

  • db_config配置文件(调用数据库的好方法,值得借鉴)

    [root@mysql01 day0330]# cat db_config.py
    import MySQLdbdb_config = {'host' : 'localhost','user' : 'root','passwd' : 'zhuima','charset' : 'utf8','db': 'txl',
    }conn = MySQLdb.connect(**db_config)
    cursor = conn.cursor()

3、连接数据库,实现增,查功能

导入db_config模块中的conn和cursor,然后直接使用

  • 代码片段

    #确保自定义模块能够被正常导入
    import sys
    module_path = '/zhuima'
    sys.path.append(module_path)# 导入自定义模块
    from db_config import conn,cursor....def txl_add():'''读取用户输入信息,并写入数据库'''name = raw_input('Please enput your name: ')gender = raw_input('Please enput your gender: ')brithday = raw_input('like (YYYY-MM-DD) >>> ')tel = raw_input('Please enput your tel: ')sql = 'insert into tb_txl  values (null,%s,%s,%s,%s)'cursor.execute(sql,(name,gender,brithday,tel))conn.commit()def txl_dis():'''从数据库中提取信息,然后打印出来 '''sql = 'select name,gender,brithday,tel from tb_txl'cursor.execute(sql)info = cursor.fetchall()#print "%s\t%s\t%s\t%s" % infoif len(info) > 0:print "name\tgender\tbrithday\ttel"print "---------------------------"#print info# 这里打印出来的结果未作处理for x in info:print x else:print print ">>> Empty,There is no user info in db <<<"#print  infodef txl_exit():'''关闭连接, 退出程序 '''cursor.close()conn.close()os._exit(0)
  • 导入模块测试(如果db_config和当前脚本不在同一个目录下面,要设定path才行)

    [root@mysql01 day0330]# python v3_1.py1.add user info2.disp all user info3.update user info by username4:del user by username5:sort user info by 0.exit programPlease select one >>> 2
    name    gender  brithday    tel
    ---------------------------
    ((u'zhuima', u'f', datetime.date(1988, 12, 8), u'10086'),)1.add user info2.disp all user info3.update user info by username4:del user by username5:sort user info by 0.exit programPlease select one >>> 1
    Please enput your name: nick
    Please enput your gender: m
    like (YYYY-MM-DD) >>> 1990-10-10
    Please enput your tel: 100101.add user info2.disp all user info3.update user info by username4:del user by username5:sort user info by 0.exit programPlease select one >>> 2
    name    gender  brithday    tel
    ---------------------------
    (u'zhuima', u'f', datetime.date(1988, 12, 8), u'10086')
    (u'nick', u'm', datetime.date(1990, 10, 10), u'10010')1.add user info2.disp all user info3.update user info by username4:del user by username5:sort user info by 0.exit programPlease select one >>> 0

4、连接数据库,实现删功能

导入db_config模块中的conn和cursor,然后直接使用

  • 代码片段

    def txl_del():
    status = True
    name = raw_input('Delete Information By Name >>> ')
    select_sql = 'select name from tb_txl'
    cursor.execute(select_sql)
    info = cursor.fetchall()
    print info
    for line in info:if name in line:status = Falsedelete_sql = 'delete from tb_txl where name=%s'cursor.execute(delete_sql,(name,))conn.commit()
    if status:printprint ">>>Unkonw User,Please Try again! <<<"
  • 测试结果 (中间添加了print来调试代码)

    [root@mysql01 day0330]# python v3_1.py1.add user info2.disp all user info3.update user info by username4:del user by username5:sort user info by 0.exit programPlease select one >>> 2
    name    gender  brithday    tel
    ------------------------------------
    (u'zhuima', u'f', datetime.date(1988, 12, 8), u'10086')
    (u'kale', u'f', datetime.date(1988, 2, 18), u'10032')1.add user info2.disp all user info3.update user info by username4:del user by username5:sort user info by 0.exit programPlease select one >>> 4
    Delete Information By Name >>> kale
    ((u'zhuima',), (u'kale',))1.add user info2.disp all user info3.update user info by username4:del user by username5:sort user info by 0.exit programPlease select one >>> 2
    name    gender  brithday    tel
    ------------------------------------
    (u'zhuima', u'f', datetime.date(1988, 12, 8), u'10086')1.add user info2.disp all user info3.update user info by username4:del user by username5:sort user info by 0.exit programPlease select one >>> 4
    Delete Information By Name >>> sdfsdf
    ((u'zhuima',),)>>>Unkonw User,Please Try again! <<<1.add user info2.disp all user info3.update user info by username4:del user by username5:sort user info by 0.exit programPlease select one >>> 0

5、连接数据库,实现更新功能

根据用户名搜索相关的值来进行更新

  • update实例演示

    mysql> select * from tb_txl;
    +----+--------+--------+------------+-------+
    | id | name   | gender | brithday   | tel   |
    +----+--------+--------+------------+-------+
    |  1 | zhuima | f      | 1988-12-08 | 10086 |
    |  6 | nick   | m      | 1990-10-06 | 10011 |
    +----+--------+--------+------------+-------+
    2 rows in set (0.00 sec)mysql> update tb_txl set tel='10010' where name='nick';
    Query OK, 1 row affected (0.22 sec)
    Rows matched: 1  Changed: 1  Warnings: 0mysql> select * from tb_txl;
    +----+--------+--------+------------+-------+
    | id | name   | gender | brithday   | tel   |
    +----+--------+--------+------------+-------+
    |  1 | zhuima | f      | 1988-12-08 | 10086 |
    |  6 | nick   | m      | 1990-10-06 | 10010 |
    +----+--------+--------+------------+-------+
    2 rows in set (0.00 sec)mysql>
  • 代码片段

    def txl_update():
    statue = True
    name = raw_input('Update Information By Name >>> ')
    select_sql = 'select name from tb_txl'
    cursor.execute(select_sql)
    info = cursor.fetchall()
    for line in info:if name in line:status = Falsegender = raw_input('Update Your Gender for %s >>> ' % name)brithday = raw_input('Update Your Brithday like (YYYY-MM-DD) for %s >>> ' % name)tel = raw_input('Update Your Tel for %s >>> '% name)update_sql = 'update tb_txl set gender=%s,brithday=%s,tel=%s where name=%s'cursor.execute(update_sql,(gender,brithday,tel,name,))conn.commit()if status:printprint ">>>Unkonw User,Please Try again! <<<"
  • 执行结果

    [root@mysql01 day0330]# python v3_1.py1.add user info2.disp all user info3.update user info by username4:del user by username5:check user info by username0.exit programPlease select one >>> 2
    name    gender  brithday    tel
    ------------------------------------
    (u'nick', u'm', datetime.date(1990, 10, 6), u'10010')
    (u'zhuima', u'f', datetime.date(1988, 12, 8), u'10086')1.add user info2.disp all user info3.update user info by username4:del user by username5:check user info by username0.exit programPlease select one >>> 3
    Update Information By Name >>> zhuima
    Update Your Gender for zhuima >>> m
    Update Your Brithday like (YYYY-MM-DD) for zhuima >>> 1990-10-10
    Update Your Tel for zhuima >>> 100001.add user info2.disp all user info3.update user info by username4:del user by username5:check user info by username0.exit programPlease select one >>> 2
    name    gender  brithday    tel
    ------------------------------------
    (u'nick', u'm', datetime.date(1990, 10, 6), u'10010')
    (u'zhuima', u'm', datetime.date(1990, 10, 10), u'10000')1.add user info2.disp all user info3.update user info by username4:del user by username5:check user info by username0.exit programPlease select one >>> 5
    Enter The name >>> sdfsdf>>>Unkonw User,Please Try again! <<<

6、连接数据库,实现检索功能

根据用户名搜索相关的值然后返显结果

  • 代码片段

    def txl_check():
    status = True
    name = raw_input('Enter The name >>> ')
    cursor.execute('select * from tb_txl')
    info = cursor.fetchall()
    for line in info:if name in line:status = Falseprint lineif status:printprint ">>>Unkonw User,Please Try again! <<<"
  • 测试结果

    [root@mysql01 day0330]# python v3_1.py1.add user info
    2.disp all user info
    3.update user info by username
    4:del user by username
    5:check user info by username
    0.exit programPlease select one >>> 5
    Enter The name >>> sdfs>>>Unkonw User,Please Try again! <<<1.add user info2.disp all user info3.update user info by username4:del user by username5:check user info by username0.exit programPlease select one >>> 5
    Enter The name >>> nick
    (6L, u'nick', u'm', datetime.date(1990, 10, 6), u'10010')1.add user info2.disp all user info3.update user info by username4:del user by username5:check user info by username0.exit programPlease select one >>>

完整代码

    #!/usr/bin/env python#coding:utf8#Author:zhuima#Date:2015-03-22#Version:0.1#Function:display a list and add date# 导入模块import os#确保自定义模块能够被正常导入import sysmodule_path = '/zhuima'sys.path.append(module_path)# 导入自定义模块from db_config import conn,cursordef menu():'''设置munu目录,提供给用户的操作接口 '''print '''1.add user info2.disp all user info3.update user info by username4:del user by username5:check user info by username0.exit program'''op = raw_input('Please select one >>> ')return opdef txl_add():'''读取用户输入信息,并写入数据库'''name = raw_input('Please enput your name: ')gender = raw_input('Please enput your gender: ')brithday = raw_input('like (YYYY-MM-DD) >>> ')tel = raw_input('Please enput your tel: ')sql = 'insert into tb_txl  values (null,%s,%s,%s,%s)'cursor.execute(sql,(name,gender,brithday,tel))conn.commit()def txl_dis():'''从数据库中提取信息,然后打印出来 '''sql = 'select name,gender,brithday,tel from tb_txl'cursor.execute(sql)info = cursor.fetchall()#print "%s\t%s\t%s\t%s" % infoif len(info) > 0:print "name\tgender\tbrithday\ttel"print "------------------------------------"#print infofor x in info:print xelse:print print ">>> Empty,There is no user info in db <<<"#print  infodef txl_del():status = Truename = raw_input('Delete Information By Name >>> ')select_sql = 'select name from tb_txl'cursor.execute(select_sql)info = cursor.fetchall()for line in info:if name in line:status = Falsedelete_sql = 'delete from tb_txl where name=%s'cursor.execute(delete_sql,(name,))conn.commit()if status:printprint ">>>Unkonw User,Please Try again! <<<"def txl_update():statue = Truename = raw_input('Update Information By Name >>> ')select_sql = 'select name from tb_txl'cursor.execute(select_sql)info = cursor.fetchall()for line in info:if name in line:status = Falsegender = raw_input('Update Your Gender for %s >>> ' % name)brithday = raw_input('Update Your Brithday like (YYYY-MM-DD) for %s >>> ' % name)tel = raw_input('Update Your Tel for %s >>> '% name)update_sql = 'update tb_txl set gender=%s,brithday=%s,tel=%s where name=%s'cursor.execute(update_sql,(gender,brithday,tel,name,))conn.commit()if status:printprint ">>>Unkonw User,Please Try again! <<<"def txl_check():status = Truename = raw_input('Enter The name >>> ')cursor.execute('select * from tb_txl')info = cursor.fetchall()for line in info:if name in line:status = Falseprint lineif status:printprint ">>>Unkonw User,Please Try again! <<<"def txl_exit():''' 退出程序 '''cursor.close()conn.close()os._exit(0)def txl_error():''' 当用户输出选项不在定义的选项内的时候,报错'''printprint 'Unkonw options,Please try again!'# 定义dict,配合函数实现switch功能ops = {'1':txl_add,'2':txl_dis,'3':txl_update,'4':txl_del,'5':txl_check,'0':txl_exit,}def main():'''主程序 '''while True:op = menu()ops.get(op,txl_error)()if __name__ == '__main__':main()

实现格式化输出

brithday输出更正为输出为具体年龄,可视化更强

  • 引入datetime模块

  • 代码片段

def txl_dis():
'''从数据库中提取信息,然后打印出来 '''
status = True
sql = 'select name,gender,brithday,tel from tb_txl'
cursor.execute(sql)
info = cursor.fetchall()
if len(info) > 0:status = Falseprint "name\tgender\tbrithday\ttel"print "------------------------------------"for name,gender,age,tel in info:today = datetime.date.today()age = (today-age).days/365print "%(name)s\t%(gender)s\t%(age)s\t\t%(tel)s" % locals()if status:print print ">>> Empty,There is no user info in db <<<"


格式化之后的初始版本的脚本:

#!/usr/bin/env python
#coding:utf8
#Author:zhuima
#Date:2015-03-22
#Version:0.1
#Function:display a list and add date# 导入模块
import os
import datetime#确保自定义模块能够被正常导入
import sys
module_path = '/zhuima'
sys.path.append(module_path)# 导入自定义模块
from db_config import conn,cursordef menu():'''设置munu目录,提供给用户的操作接口 '''print '''1.add user info2.disp all user info3.update user info by username4:del user by username5:check user info by username0.exit program'''op = raw_input('Please select one >>> ')return opdef txl_add():'''读取用户输入信息,并写入数据库'''name = raw_input('Please enput your name: ')gender = raw_input('Please enput your gender: ')brithday = raw_input('like (YYYY-MM-DD) >>> ')tel = raw_input('Please enput your tel: ')sql = 'insert into tb_txl  values (null,%s,%s,%s,%s)'cursor.execute(sql,(name,gender,brithday,tel))conn.commit()def txl_dis(name=None):'''从数据库中提取信息,然后打印出来 '''status = Truesql = 'select name,gender,brithday,tel from tb_txl'cursor.execute(sql)info = cursor.fetchall()if len(info) > 0:status = Falseprint "name\tgender\tage\ttel"print "------------------------------------"for name,gender,age,tel in info:today = datetime.date.today()age = (today-age).days/365print "%(name)s\t%(gender)s\t%(age)s\t%(tel)s" % locals()if status:print print ">>> Empty,There is no user info in db <<<"#print  infodef txl_del():status = Truename = raw_input('Delete Information By Name >>> ')select_sql = 'select name from tb_txl'cursor.execute(select_sql)info = cursor.fetchall()for line in info:if name in line:status = Falsedelete_sql = 'delete from tb_txl where name=%s'cursor.execute(delete_sql,(name,))conn.commit()if status:printprint ">>>Unkonw User,Please Try again! <<<"def txl_update():statue = Truename = raw_input('Update Information By Name >>> ')select_sql = 'select name from tb_txl'cursor.execute(select_sql)info = cursor.fetchall()for line in info:if name in line:status = Falsegender = raw_input('Update Your Gender for %s >>> ' % name)brithday = raw_input('Update Your Brithday like (YYYY-MM-DD) for %s >>> ' % name)tel = raw_input('Update Your Tel for %s >>> '% name)update_sql = 'update tb_txl set gender=%s,brithday=%s,tel=%s where name=%s'cursor.execute(update_sql,(gender,brithday,tel,name,))conn.commit()if status:printprint ">>>Unkonw User,Please Try again! <<<"def txl_check():status = Truename = raw_input('Enter The name >>> ')sql = 'select name,gender,brithday,tel from tb_txl where name = %s' cursor.execute(sql,(name,))info = cursor.fetchall()if len(info) > 0:status = Falseprint "name\tgender\tbrithday\ttel"print "------------------------------------"for name,gender,age,tel in info:today = datetime.date.today()age = (today-age).days/365print "%(name)s\t%(gender)s\t%(age)s\t%(tel)s" % locals()if status:print print ">>> Empty,There is no user info in db <<<"def txl_exit():''' 退出程序 '''cursor.close()conn.close()os._exit(0)def txl_error():''' 当用户输出选项不在定义的选项内的时候,报错'''printprint 'Unkonw options,Please try again!'def main():'''主程序 '''# 定义dict,配合函数实现switch功能ops = {'1':txl_add,'2':txl_dis,'3':txl_update,'4':txl_del,'5':txl_check,'0':txl_exit,}while True:op = menu()ops.get(op,txl_error)()if __name__ == '__main__':main()


脚本中存在着很多重复代码以及bug,仅作参考,如果哪位想要调试可以进行下载重新更改



本文转自lovelace521 51CTO博客,原文链接:http://blog.51cto.com/lovelace/1631831,如需转载请自行联系原作者

相关文章:

#每天一种设计模式# 模板方法

《松本行弘的程序世界》对模板方法(Template method)的说明非常清晰&#xff1a; 在父类的一个方法中定义算法的框架&#xff0c;其中几个步骤的具体内容则留给子类来实现。 比如一个用于公司欢迎同事的程序&#xff1a; class Adef initializename "jinbin"word …

如何更好地玩转GitHub?

本文作者黄昱俊&#xff0c;国资企业投资部总经理&#xff0c;主要负责投资部门建设、投资流程管理、投后资源管理。历经10年&#xff0c;从医疗器械研发工程师到投资管理的蜕变&#xff0c;业余尝试ETF量化投资。 本文介绍如何在GitHub上更新Fork以及PullRequest给源项目。 在…

System Center Data Protection Manager 2007补助说明

在 DPM 服务器上配置 Windows 防火墙 1. 在 Control Panel&#xff08;控制面板&#xff09;中&#xff0c;单击 Windows Firewall&#xff08;Windows 防火墙&#xff09;。2. 在 General&#xff08;常规&#xff09;选项卡中&#xff0c;验证是否已开启 Windows 防火墙&am…

可伸缩系统的设计模式(译)

Ricky Ho在他的博客中分享了该文章&#xff0c;该文章是一个简单的概括分享&#xff0c;详细的可以参见他博客的其它详细文章。下面主要是意译。 1、Load Balancer&#xff1a;负载均衡 – 由分发者来决定哪个工作者处理下一个请求&#xff0c;这种决定可以基于不同的策略。 “…

Boson_Netsim_6使用方法

使用说明&#xff1a; netsim6.0只有在英文操作系统下才能释放出正确的pdf文件&#xff0c;大家可以到文档中心下载以下3个pdf文件&#xff1a; SequentialLabs.pdf&#xff1a;解压后复制到安装目录下的\MyLabs\ccna_sequential\Sequential Labs (CCNA)\common中覆盖相应的文件…

Ruby之Enumerator类

今天发现了Ruby1.8.6和 Ruby1.9.2的一个不同之处&#xff0c;试运行以下代码&#xff1a; require findputs Find.find("./data").class 在Ruby1.9.2中&#xff0c;最后的结果是Enumerator&#xff0c;而在Ruby1.8.6中&#xff0c;结果则是find: no block given (L…

澎思科技获IDG资本数千万元Pre-A轮融资  推出AI安防全场景软硬件解决方案

1月8日&#xff0c;人工智能安防公司澎思科技宣布完成数千万元 Pre-A 轮融资&#xff0c;该轮融资由 IDG 资本领投&#xff0c;高捷资本、上古资本、洪泰基金跟投。澎思科技表示&#xff0c;此轮融资会更多用来“修炼内功”&#xff0c;进一步夯实公司的技术研发和产品落地能力…

看linux书籍做的一些重要笔记(2011.07.03更新)

&#xff08;1&#xff09;制作启动盘 •用户可以用dd&#xff0c;cat&#xff0c;cp等命令自行将这些image文件制作成启动盘。 •例如&#xff1a; •ddif/mnt/cdrom/RedHat/images/bootdisk.img of/dev/fd0 •cp /mnt/cdrom/RedHat/images/bootdisk.img /dev/fd0 •cat /mnt…

C++ Primer 读书笔记 (1)

我的《C Primer》扉页记着购书的日期和地点&#xff1a;C Primer 2009.11.28购于西区求索。那时对于这本厚书一直心怀敬畏&#xff0c;仿佛是眼前的一座大山。那时&#xff0c;虽然已经大四&#xff0c;但是对于面向对象的理解还很肤浅(相当肤浅)&#xff0c;只能用C编写一些简…

招聘:兼职ASP 高级工程师

工作职责&#xff1a;1、负责ASP网站设计和页面制作&#xff1b;2、配合运营团队做客户服务支持&#xff1b;3、参与海洋工作室其他相关设计工作。 职位描述&#xff1a; 1. 要求有很强大ASP开发功底;2. SQL Server使用经验;3. 有与策划者和美工合作的习惯;4. 可独立开发&…

GitHub重大好消息:私有仓库可无限制免费创建

作者 | 一一 出品 | AI科技大本营 GitHub 被微软收购之后&#xff0c;第一次公布了有利于广大程序员的好消息。 1 月 8 日&#xff0c;GitHub 宣布无限制的免费为普通用户提供私有仓库服务&#xff0c;这给程序员每年省下了 84 美元。此前&#xff0c;企业要创建私有仓库进行代…

“AI下乡”:华为和袁隆平一起种海水稻,欲改造1亿亩良田

作者| 琥珀 出品| AI科技大本营我们总是无法忘怀“杂交水稻之父”袁隆平的名字&#xff0c;即便后来很多学者对他的成就有所争议。距今&#xff0c;三系杂交水稻的发现已经过去了 50 多年&#xff0c;袁隆平也近 90 岁高龄&#xff0c;但他依然活跃在农业生产一线。想必近日不少…

finecms设置伪静态后分享到微信不能访问怎么处理

finecms设置伪静态后分享到微信不能访问&#xff0c;分享的链接自动增加了一串参数&#xff0c;类似这样的***.html?fromsinglemessage&isappinstalled0&#xff0c;刚开始ytkah没注意&#xff0c;以为是微信屏蔽了不安全网址&#xff0c;后面在论坛上问了一下&#xff0c…

Access和SQL server开启表间关系,并实现更新或删除母表数据自动更新或删除子表数据...

1.Access开启表间关系,并实现删除母表数据自动删除子表数据: 在Tables等界面 - > 右键 - > Relationships... -> 弹出Relationships窗口 -> 选择需要关联的表 -> 双击Relationships窗口空白位置 -> 弹出 Edit Relationships 窗口 -> 就可以看到Enforce Re…

推荐并简要分析一个silverlight的相册DEMO--ImageSnipper(V2)

下面就是它的一些演示截图。 首先是缩放&#xff0c;旋转和透明处理&#xff1a;然后是文字水印处理&#xff1a;然后是使用Ink的涂鸭&#xff1a;相信做为一个相册&#xff08;图片浏览&#xff09;的基本功能已经没什么问题了。下面来看一下这个DEMO的类图&#xff…

Ruby之Tempfile

今天又机会尝试了下Ruby的Tempfile库&#xff0c;相比于自己创建临时文件再删除的方法简便了很多。 require tempfiletmp Tempfile.new("tmp")tmp.path # > /tmp/tmp20110928-12389-8yyc6w 不唯一tmp.write("This is a tempfile") tmp.rewind tmp.read…

快车 FlashGet 3.1 修正版(1057)

快车 FlashGet 3.1 修正版(1057) SM发布于 2009-06-25 23:43:23| 2326 次阅读 字体&#xff1a;大 小 打印预览感谢VxuE的投递快车(FlashGet)是互联网上最流行,使用人数最多的一款下载软件.采用多服务器超线程技术、全面支持多种协议,具有优秀的文件管理功能.快车是绿色软件,无…

Python模拟微博登陆,亲测有效!

作者 l 上海小胖 来源 l Python专栏&#xff08;ID&#xff1a;xpchuiit&#xff09;转载请联系授权&#xff08;微信ID&#xff1a;pythonzhuanlan&#xff09;今天想做一个微博爬个人页面的工具&#xff0c;满足一些不可告人的秘密。那么首先就要做那件必做之事&#xff01…

Ruby调用shell命令

原来发在diandian的几篇旧闻&#xff0c;也一并转到iteye上来吧。 1. exec exec echo "hello $HOSTNAME" 用echo命令来取代当前进程&#xff0c;无法知道命令是否成功 2. system system(echo "hello $HOSTNAME") 运行一个子shell来避免覆盖当前进程&a…

mac os下valgrind的安装

valgrind是一款性能分析工具&#xff0c;功能强大。 在mac os下的安装略有不同&#xff0c;特写此文以记之。 现在最新的版本是3.8.1 tar jxvf valgrind-3.8.1.tar.bz2 cd valgrind-3.8.1 ./configure sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer m…

Google Voice开始发送邀请函

今天收到了Google Voice的邀请函&#xff0c;标题为“Youve been invited to Google Voice”。最近关于Google Voice 的新闻不少&#xff0c;出于好奇登录http://www.google.com/voice 递交了申请&#xff0c;没有想到这么快得到了邀请函。邮件特别强调“ Please note that Goo…

Python开发(基础):字符串

字符串常用方法说明 #!/usr/bin/env python # -*- coding:utf-8 -*- # class str(basestring): # """ # str(object) -> string # # Return a nice string representation of the object. # If the argument is a string, the return value …

Linux与Windows文件共享命令 rz,sz

一般来说&#xff0c;linux服务器大多是通过ssh客户端来进行远程的登陆和管理的&#xff0c;使用ssh登陆linux主机以后&#xff0c;如何能够快速的和本地机器进行文件的交互呢&#xff0c;也就是上传和下载文件到服务器和本地&#xff1b; 与ssh有关的两个命令可以提供很方便的…

Python爬虫小偏方:如何用robots.txt快速抓取网站?

作者 | 王平&#xff0c;一个IT老码农&#xff0c;写Python十年有余&#xff0c;喜欢分享通过爬虫技术挣钱和Python开发经验。来源 | 猿人学Python在我抓取网站遇到瓶颈&#xff0c;想剑走偏锋去解决时&#xff0c;常常会先去看下该网站的robots.txt文件&#xff0c;有时会给你…

八百客与51CTO结了梁子?

转载于:https://blog.51cto.com/simon/171348

特斯拉“撞死”机器人,是炒作还是事故?

作者 | 若名出品 | AI科技大本营科幻片里机器人大战的剧情可能离人类还很遥远&#xff0c;但设想一下&#xff0c;现实中机器人不受控制的打起架来...1 月 6 日&#xff0c;一辆处于自动驾驶模式的特斯拉 Model S “撞死”了一辆掉队 Promobot 的机器人。本次撞击事件发生在当地…

网页解析:如何获得网页源码中嵌套的标签。

一&#xff1a;前言&#xff1a;网页源码中有很多嵌套的标签 例如div标签嵌套如&#xff1a;bUTP<DIV>finally<div>aurora</div>126.com</div><div class\"Cited1\">ggff</div> 我们的网页解析工作中有时候需要解嵌套。通俗的讲…

36.intellij idea 如何一键清除所有断点

转自&#xff1a;https://www.cnblogs.com/austinspark-jessylu/p/7799212.html 1.在idea左下方找到"View Breakpoints"按钮,点击打开. 2.点击"Java Line Breakpoints"前方的全选框,取消全选. 3.点击上方"-"即"Remove"按钮,即可取消所…

Ruby与vim

介绍一点vim下使用Ruby的技巧。 1. vim命令行模式下输入 !ruby % 可以直接运行Ruby程序&#xff0c;并返回到vim编辑 2. vim Ruby关键字及自定义变量补全 拷贝附录中的ruby-macros.vim至机器某处&#xff0c;然后修改~/.vimrc&#xff0c;添加一行&#xff1a; source ROOT(…

NLP技术落地为何这么难?里面有哪些坑?

AI 很火&#xff0c;但是 AI 的门槛也很高&#xff0c;普通的开发者想要搭上这波 AI 红利依然困难。近期&#xff0c;人工智能公司推出了新一代智能 Bot 开放平台&#xff0c;它整合了小i机器人 Chatting Bot、FAQ Bot、Discovery Bot 三大核心能力&#xff0c;为企业和开发者提…