版本21和22间的区别
于2006-06-10 18:26:15修订的的版本21
大小: 4072
编辑: czk
备注:
于2006-06-10 18:28:53修订的的版本22
大小: 4126
编辑: czk
备注:
删除的内容标记成这样。 加入的内容标记成这样。
行号 6: 行号 6:
Paradigm: Multi-paradigm
Appeared in:  1990
Designed by:  Guido van Rossum
Developer:  Python Software Foundation
Latest release:  2.4.3 / March 29, 2006
Typing discipline:  Strong, dynamic ("duck")
Major implementations:  CPython, Jython, IronPython, PyPy
Influenced by:  ABC, Modula-3, Icon, C, Perl, Lisp, Smalltalk, Tcl
Influenced:  Ruby, Boo
OS:  Cross-platform
License: Python Software Foundation License
Website: www.python.org
||Paradigm:||Multi-paradigm||
||
Appeared in:||1990||
||
Designed by:||Guido van Rossum||
||
Developer:||Python Software Foundation||
||
Latest release:||2.4.3 / March 29, 2006||
||
Typing discipline:||Strong, dynamic ("duck")||
||
Major implementations:||CPython, Jython, IronPython, PyPy||
||
Influenced by:||ABC, Modula-3, Icon, C, Perl, Lisp, Smalltalk, Tcl||
||
Influenced:|| Ruby, Boo||
||
OS:|| Cross-platform||
||
License:|| Python Software Foundation License||
||
Website:|| www.python.org||

TableOfContents

Python语言

1. Summary

Paradigm:

Multi-paradigm

Appeared in:

1990

Designed by:

Guido van Rossum

Developer:

Python Software Foundation

Latest release:

2.4.3 / March 29, 2006

Typing discipline:

Strong, dynamic ("duck")

Major implementations:

CPython, Jython, IronPython, PyPy

Influenced by:

ABC, Modula-3, Icon, C, Perl, Lisp, Smalltalk, Tcl

Influenced:

Ruby, Boo

OS:

Cross-platform

License:

Python Software Foundation License

Website:

www.python.org

2. Pythonic

A few neologisms have come into common use within the Python community. One of the most common is "pythonic", which can have a wide range of meanings related to program style. To say that a piece of code is pythonic is to say that it uses Python idioms well; that it is natural or shows fluency in the language. Likewise, to say of an interface or language feature that it is pythonic is to say that it works well with Python idioms; that its use meshes well with the rest of the language.

In contrast, a mark of unpythonic code is that it attempts to "write C++ (or Lisp, or Perl) code in Python"—that is, provides a rough transcription rather than an idiomatic translation of forms from another language.

The prefix Py- can be used to show that something is related to Python. Examples of the use of this prefix in names of Python applications or libraries include Pygame, a binding of SDL to Python (commonly used to create games), PyUI, a GUI encoded entirely in Python, and PySol, a series of solitaire card games programmed in Python.

Users and admirers of Python—most especially those considered knowledgeable or experienced—are often referred to as Pythonists, Pythonistas, and Pythoneers

3. Python的编码处理技术

对于中文用户,特别需要关注Python的编码技术. 列举一些常用的技巧。

chr(i): 将一个0到255的整数转换为一个字符.
ord(c): 返回单个字符c的整数顺序值.普通字符返回[0,255]中的一个值,Unicode字符返回 [0,65535]中的一个值
unichr(i): 将一个0到65535的整数转换为一个Unicode字符
  • 代码中的编码设置,应该在代码最初两行内包含:

# -*- coding: UTF-8 -*-
  • 获得/设置系统的缺省编码

sys.getdefaultencoding()

sys.setdefaultencoding('utf-8')
  • 获得文件系统的文件名的编码

sys.getfilesystemencoding()
  • 获得当前终端的输入、输出编码

      sys.stdout.encoding

      sys.stdin.encoding
  • 编码转换(先转换为unicode,再转换为具体的编码),有两种方法:

      unicode('abc', 'mbcs').encode('utf-8')

      'abc'.decode('mbcs').encode('utf-8')

Python库

学习资料

Python (2020-06-05 17:12:03由czk编辑)

ch3n2k.com | Copyright (c) 2004-2020 czk.