随笔分类 -  python

摘要:配置文件作为一种可读性很好的格式,非常适用于存储程序中的配置数据。 在每个配置文件中,配置数据会被分组(比如“config”和 “cmd”)。 每个分组在其中指定对应的各个变量值。如下: 基本的读取操作: -read(filename) 直接读取文件内容 -sections() 得到所有的secti 阅读全文
posted @ 2017-07-25 16:03 anlcy 阅读(21194) 评论(0) 推荐(0)
摘要:我们可以在python的交互环境下编写执行代码,但这只是适合短的代码,当有长的代码时在这里编写就不方便, Python有自带的IDE,根据自己使用的情况来看,感觉Pycharm这款IDE比自带的IDE好用,下面介绍Pycharm 的下载及安装: 1、下载 登录Pycharm官网下载Pycharm的安 阅读全文
posted @ 2017-07-25 10:42 anlcy 阅读(3754) 评论(0) 推荐(0)
摘要:# -*- coding:utf-8 -*-#导入模块from selenium import webdriverfrom selenium.common.exceptions import NoSuchElementException#选择浏览器driver = webdriver.Firefox 阅读全文
posted @ 2017-07-21 15:40 anlcy 阅读(610) 评论(0) 推荐(0)
摘要:来自:https://www.runoob.com/python3/python3-tutorial.html 1.使用循环嵌套来实现99乘法法则: for i in range(1,10): for j in range(1,i+1): sun=i*j print('%d*%d=%d'%(j,i, 阅读全文
posted @ 2017-07-18 09:35 anlcy 阅读(319) 评论(0) 推荐(0)
摘要:一:时间转成秒数 stackoverflow.com上还有更多的写法 http://stackoverflow.com/questions/10663720/converting-a-time-string-to-seconds-in-python http://stackoverflow.com/ 阅读全文
posted @ 2017-07-13 16:45 anlcy 阅读(1272) 评论(0) 推荐(0)
摘要:# -*- coding:utf-8 -*- #模仿自: http://www.jianshu.com/p/f893291674ca#python恶俗古风诗自动生成器from random import sampleimport timeimport oswords="""朱砂 天下 杀伐 人家 韶 阅读全文
posted @ 2017-07-13 16:40 anlcy 阅读(1887) 评论(0) 推荐(0)
摘要:# -*- coding:utf-8 -*-#用python生产包含电话号码的代码temp = """arr = %sindex = %stel = ''for i in index: tel += arr[i]print("电话号码" + tel)"""def encode(tel): arr = 阅读全文
posted @ 2017-07-13 15:58 anlcy 阅读(1520) 评论(0) 推荐(0)
摘要:直接从浏览器中取出cookies,有以下好处和用途: 1、不需要配置用户密码,直接读出浏览器中cookies就得到一样的身份,用来完成各种自动化操作。 2、部分网站登录会更新Session,会导致之前成功登录的Session失效,与浏览器使用相同的Session,不用进行登录操作,不会互相挤下线。 阅读全文
posted @ 2017-07-13 15:39 anlcy 阅读(5728) 评论(0) 推荐(0)
摘要:1.通过浏览器获取登录cookie,找到重要的两个参数“BAIDUID”和“BDUSS”; 2.编写Selenium自动化测试脚本,跳过登录。 from selenium import webdriverdriver = webdriver.Chrome()driver.get("https://w 阅读全文
posted @ 2017-07-13 15:38 anlcy 阅读(1188) 评论(0) 推荐(0)
摘要:Python 的 re 模块(Regular Expression 正则表达式)提供各种正则表达式的匹配操作,和 Perl 脚本的正则表达式功能类似,使用这一内嵌于 Python 的语言工具,尽管不能满足所有复杂的匹配情况,但足够在绝大多数情况下能够有效地实现对复杂字符串的分析并提取出相关信息。Py 阅读全文
posted @ 2017-07-10 11:16 anlcy 阅读(1209) 评论(0) 推荐(0)
摘要:最初Python2写法: #!/usr/bin/env python # -*- coding:utf-8 -*- # -*- author:nancy -*- # python2抓取bing主页所有背景图片 import urllib,re,sys,os def get_bing_backphot 阅读全文
posted @ 2017-07-10 11:03 anlcy 阅读(512) 评论(0) 推荐(0)