python学习
K_Lily
靡不有初,鲜克有终
展开
-
在linux跑python脚本将数据输出到文件中
有时候python代码必须要在linux环境运行在xshell运行脚本,将文件输出到文件不能使用下面的方法输出import jsonwith open("tmp.txt", "w") as fp: fp.write(json.dumps(tmp))在xshell中只需要将输出重定向一下就ok啦~使用办法python xxx.py > xxx.log然后在...原创 2020-04-30 10:49:21 · 2426 阅读 · 0 评论 -
手机号、身份证、邮箱号等正则匹配表达式
1、校验中文字符串只是中文^[\\u4e00-\\u9fa5]{0,}$2、 校验E-Mail 地址[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\\w](?:[\\w-]*[\\w])?\\.)+[\\w](?:[\\w-]*[\\w])?3、校验身份证号码15位^[...原创 2020-04-27 17:04:47 · 579 阅读 · 0 评论 -
python基础for循环使用
将1、2、3、4四个数字,能组成互不相同且无重复数字的三位数#!/usr/bin/python# -*- coding: UTF-8 -*- for i in range(1,5): for j in range(1,5): for k in range(1,5): if( i != k ) and (i != j) and (j !=...原创 2020-04-20 17:44:46 · 356 阅读 · 0 评论