`
445822357
  • 浏览: 740704 次
文章分类
社区版块
存档分类
最新评论

python tips(4)

 
阅读更多

1. python实现IE自动化,可使用cPAMIE模块。

使用方法:

import cPAMIE

ie = cPAMIE.PAMIE()

ie.Navigate()用来访问一个链接,常用的方法还有ie.SetTextBox(), ie.SetListBox(), ie.ClickButton(), GoBack(), Refresh(), Quit()等。

另外常用的ie集成测试工具可用selenium(IE、firefox可用)。

2. 常见的Http Status Code:

404->请求的网页不存在

503->服务不可用

200->服务器成功返回网页

3. 常用的HTML和XML中的转义字符:

HTML:

&lt; <

&gt; >

&amp; &

&quot; "

&nbsp; (空格)

&copy; ©(版权符)

&reg; ®(注册符)

XML:

&lt; <

&gt; >

&amp; &

&apos; '

&quot; "

4. 安装完毕python后可在安装目录下发现python.exe和pythonw.exe,它们在视窗运行时调用不同的执行档案。前者运行.py文件,后者运行.pyw文件。

跟python.exe比较,pythonw.exe有以下不同:

1)执行时不会弹出控制台窗口(也叫DOS窗口)

2)所有向原有的stdout和stderr的输出都无效

3)所有从原有的stdin的读取都只会得到EOF

.pyw格式是被设计来运行开发完成的纯图形界面程序的。

纯图形界面程序的用户不需要看到控制台窗口,开发这种程序的时候,可以暂时把.pyw改成.py,以便运行时能调出控制台窗口,看到所有错误信息,方便debug。

注意唯独视窗版python有.pyw格式。

5. pygame是利用SDL库写就的游戏库。SDL全名Simple DirectMedia Layer,用C写的,pygame即为python中使用它的库。
可以从www.pygame.org获取pygame包。以下方法可以查看安装的pygame版本。

import pygame
print pygame.ver
>>> 
1.9.1release
>>> 

就产品而言,pygame更致力于2D游戏的开发。
有些模块可能在某些平台上不存在,可以用None测试下。如下所示。

import pygame
if pygame.font is None:
    print "..."
    exit()
分享到:
评论

相关推荐

    Python-PythonTips一些初学者到中级用户的Python技巧

    Python Tips 一些初学者到中级用户的Python技巧

    python-tips-tricks:Python技巧与窍门

    Python技巧与窍门有关Python的一些技巧和窍门。有用的文件-BeautifulSoup库的概述,以便解析XML文件。 -概述Oletools库,以便检查VB代码 -Pyspark库概述-Sweetviz库概述帮助您找到所有缺少的值并显示它们-获取文件的...

    五个Python编程Tips,帮你提高编码效率.doc

    五个Python编程Tips,帮你提高编码效率.doc

    Data-Wrangling-with-Python-Tips-and-Tools-to-Make-Your-Life-Easier.pdf.pdf

    Data-Wrangling-with-Python-Tips-and-Tools-to-Make-Your-Life-Easier.pdf

    Illustrated Guide to Python 3

    Packed with Useful Hints and Tips You'll learn the best practices without wasting time searching or trying to force Python to be like other languages. I've collected all the gems I've gleaned over ...

    Serious Python

    An indispensable collection of practical tips and real-world advice for tackling common Python problems and taking your code to the next level. Features interviews with high-profile Python developers ...

    tips.txt为python数据分析案例数据

    python数据分析案例数据 主要用于本人博客的部分文章案例数据使用。 单变量的样本分布检验(python3) 探索变量间关系 ....... 等文章的案例数据

    Clean Python.pdf

    The main goal of this book is to provide tips to Python developers of various levels so they can write better Python software and programs. This book gives you various techniques irrespective of the ...

    tips_python_

    python练习数据。机器人理财是将人工智能导入传统的理财顾问服务,并非由实体的机器人帮助客户理财,而是透过网络线上互动,依据需求者设定的投资目的及风险承受度,透过计算机程序的算法,提供自动化的投资组合建议...

    Python.Unit.Test.Automation.pdf

    Quickly learn how to automate unit testing of Python 3 code with Python 3 automation libraries, such as doctest, unittest, nose, nose2, and pytest. This book explores the ...Chapter 6: Tips and Tricks

    自动办公实用tips Python自动发送邮件

    使用Python实现自动化邮件发送,可以让你摆脱繁琐的重复性业务,可以节省非常多的时间。我们把报表做出来以后一般都是需要发给别人查看,对于一些每天需要发的报表或者是需要一次发送多份的报表,这个时候可以考虑...

    Python Graphics

    Python developers looking for tips on how to create illustrations and visualizations, as well as scientists, engineers, or students using Python. It assumes familiarity with vectors, matrices, ...

    Data Wrangling with Python

    Data Wrangling with Python 全面掌握用Python进行爬虫抓取以及数据清洗与分析的方法 轻松实现高效数据处理 https://item.jd.com/12219342.html

    英文原版-Programming Python Programming Guide For Beginners Learn In a Day 2nd Edition

    These fun and easy tips transform the dreaded chore of learning a new programming language into a fun process. You'll be proud to show off your new skills to your friends and family! What are the ...

    KBEngine-Python-Tips-master.zip

    这个项目是为了给KBEngine服务端编写Python脚本的时候,让IDE有语法提示。

    Modern.Python.Cookbook.epub

    Chapter 4. Built-in Data Structures – list, set, dict Chapter 5. User Inputs and Outputs Chapter 6. Basics of Classes and Objects Chapter 7. More Advanced Class Design Chapter 8. Functional and ...

    Python小tips

    收录python基础库中sys、pathlib、arrow、configParser等基础库的用法,以及其它基础知识

    Coding project in python

    When they are feeling more confident, kids can think creatively and use the tips and tricks provided to personalize and adapt each project. The simple, logical steps in Coding Projects in Python are...

    Beginning Python Games Development(Apress,2ed,2015)

    Learn how to create compelling ... You can also capitalize upon numerous tips and tricks the authors have accumulated over their careers creating games for some of the world's largest game developers.

Global site tag (gtag.js) - Google Analytics