上一页 1 ··· 35 36 37 38 39 40 41 42 43 ··· 60 下一页

2018年4月2日

python 字典格式嵌套,相同项做叠加

摘要: all_dict = {} for tg_id in ['com.qq_a','com.qq_b','com.qq_c','com.qq_c']: tmp_dict = all_dict.get(tg_id,{'times':0}) tmp_dict['times'] += 123 all_dict[tg_id] = tmp_dict print(all_dict)... 阅读全文

posted @ 2018-04-02 21:22 星河赵 阅读(380) 评论(0) 推荐(0)

linux环境变量设置 以及 source命令 Linux 之 /etc/profile、~/.bash_profile 等几个文件的执行过程 Linux 设置环境变量

摘要: 定制环境变量 环境变量是和Shell紧密相关的,用户登录系统后就启动了一个Shell。对于Linux来说一般是bash,但也可以重新设定或切换到其它的Shell。环境变量文件:/etc/profile。 环境变量是通过Shell命令来设置的,设置好的环境变量又可以被所有当前用户所运行的程序所使用。对 阅读全文

posted @ 2018-04-02 20:24 星河赵 阅读(1485) 评论(0) 推荐(0)

python URLObject url处理模块

摘要: 1、需求来源 给一个url串,例如https://github.com/zacharyvoase/urlobject?spam=eggs#foo,想要截取串中某个部分,比如传输协议(https)、服务器名称、用户名密码、路径信息、后面query等。自己能想到的主要由以下几种方法: (1)正则 (2) 阅读全文

posted @ 2018-04-02 19:09 星河赵 阅读(1399) 评论(0) 推荐(0)

python 在Unicode和普通字符串 str 之间转换

摘要: unicodestring = u"Hello world" # 将Unicode转化为普通Python字符串:"encode" utf8string = unicodestring.encode("utf-8") asciistring = unicodestring.encode("ascii") isostring = unicodestring.encode("ISO-88... 阅读全文

posted @ 2018-04-02 15:44 星河赵 阅读(10490) 评论(0) 推荐(0)

2018年3月30日

python两个字典合并,两个list合并

摘要: 1.两个字典:a={'a':1,'b':2,'c':3} b= {'aa':11,'bb':22,'cc':33} 合并1:dict(a,**b) 操作如下: 合并2:dict(a.items()+b.items()) 如下: 合并3:c = {} c.update(a) c.update(b) 输 阅读全文

posted @ 2018-03-30 11:41 星河赵 阅读(44284) 评论(0) 推荐(1)

2018年3月29日

Mac 命令行安装mysql homebrew 安装mysql后,如何配置mysql

摘要: 非常好 强力推荐 这个是我最新并且一直推崇的方法:1、安装:sunyichaodeMacBook-Pro:~ sunyichao$ brew install mysql2、开启mysql:mysql.server start2、使用mysql的配置脚本:/usr/local/opt/mysql/bi 阅读全文

posted @ 2018-03-29 18:59 星河赵 阅读(378) 评论(0) 推荐(0)

python 将字符串转换为字典

摘要: json越来越流行,通过python获取到json格式的字符串后,可以通过eval函数转换成dict格式: >>> a='{"name":"yct","age":10}' >>> eval(a) {'age': 10, 'name': 'yct'} >>> a='{"name":"yct","age 阅读全文

posted @ 2018-03-29 15:26 星河赵 阅读(227) 评论(0) 推荐(0)

python 高阶函数 map lambda filter等

摘要: map 描述 map() 会根据提供的函数对指定序列做映射。 第一个参数 function 以参数序列中的每一个元素调用 function 函数,返回包含每次 function 函数返回值的新列表。 map计算两个列表各个元素的平方 提供两个列表对相同位置的元素相加 阅读全文

posted @ 2018-03-29 14:31 星河赵 阅读(157) 评论(0) 推荐(0)

python 类的使用实例方法

摘要: class A: dict_1 = 456 def __init__(self): self.dict_1 = 'abcdsafdsf' #当增加@staticmethod 时为类方法 @staticmethod def edf(): print '\nstatic method edf' #为实例方法 a = ... 阅读全文

posted @ 2018-03-29 11:28 星河赵 阅读(225) 评论(0) 推荐(0)

2018年3月26日

python读取excel,数字都是浮点型,日期格式是数字的解决办法

摘要: #!/usr/bin/env python # -*- encoding: utf-8 -*- import xlrd import sys reload(sys) sys.setdefaultencoding('utf-8') import traceback from datetime import datetime from xlrd import xldate_as_tuple from... 阅读全文

posted @ 2018-03-26 16:19 星河赵 阅读(465) 评论(0) 推荐(0)

上一页 1 ··· 35 36 37 38 39 40 41 42 43 ··· 60 下一页

导航