Python Strings用法

来源:互联网 发布:python turtle库安装 编辑:程序博客网 时间:2024/06/16 16:45
0.在线参考资料:
     0.1-http://thepythonguru.com/python-strings/

1.
     chr()
chr(i)

Return the string representing a character whose Unicode code point is the integeri. For example, chr(97) returns the string 'a'. This is the inverse oford(). The valid range for the argument is from 0 through 1,114,111 (0x10FFFF in base 16).ValueError will be raised if i is outside that range.

根据ascii码返回某个字符,注意函数参数需要写为 0x XX



     ord()
ord(c)

Given a string representing one Unicode character, return an integer representing the Unicode code point of that character. For example,ord('a') returns the integer 97 and ord('\u2020') returns8224. This is the inverse of chr().

               返回某个字符对应的ascii码的十进制表示

2、capitalize
     str.capitalize()

Return a copy of the string with its first character capitalized and the rest lowercased.

3、
     str.isupper()

Return true if all cased characters [4] in the string are uppercase and there is at least one cased character, false otherwise.

str.lower()

Return a copy of the string with all the cased characters[4] converted to lowercase.


The lowercasing algorithm used is described in section 3.13 of the Unicode Standard.
4、
str.join(iterable)

Return a string which is the concatenation of the strings in theiterable iterable. A TypeError will be raised if there are any non-string values in iterable, including bytes objects. The separator between elements is the string providing this method.
5、
str.lower()

Return a copy of the string with all the cased characters[4] converted to lowercase.


For 8-bit strings, this method is locale-dependent.
6、
string.lower(s)

Return a copy of s, but with upper case letters converted to lower case.







0 0