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 星河赵 阅读(374) 评论(0) 推荐(0)

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

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

posted @ 2018-04-02 20:24 星河赵 阅读(1468) 评论(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 星河赵 阅读(1396) 评论(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 星河赵 阅读(10488) 评论(0) 推荐(0)

导航