中国开发网: 论坛: 超级垃圾站: 贴子 741845
leejd
Documentation
Documentation
capitalize
std::string capitalize(const std::string & str)

Return a copy of the string with only its first character capitalized.

center
std::string center(const std::string & str, int width)

Return centered in a string of length width. Padding is done using spaces.

count
int count( const std::string & str, const std::string & substr, int start = 0, int end = MAX_32BIT_INT)

Return the number of occurrences of substring sub in string Sstart:end. Optional arguments start and end are interpreted as in slice notation.

endswith
bool endswith( const std::string & str, const std::string & suffix, int start = 0, int end = MAX_32BIT_INT)

Return True if the string ends with the specified suffix, otherwise return False. With optional start, test beginning at that position. With optional end, stop comparing at that position.

expandtabs
std::string expandtabs( const std::string & str, int tabsize = 8)

Return a copy of the string where all tab characters are expanded using spaces. If tabsize is not given, a tab size of 8 characters is assumed.

find
int find( const std::string & str, const std::string & sub, int start = 0, int end = MAX_32BIT_INT )

Return the lowest index in the string where substring sub is found, such that sub is contained in the range [start, end). Optional arguments start and end are interpreted as in slice notation. Return -1 if sub is not found.

index
int index( const std::string & str, const std::string & sub, int start = 0, int end = MAX_32BIT_INT )

Synonym of find right now. Python version throws exceptions. This one currently doesn't.

isalnum
bool isalnum( const std::string & str )

Return true if all characters in the string are alphanumeric and there is at least one character, false otherwise.

isalpha
bool isalpha( const std::string & str )

Return true if all characters in the string are alphabetic and there is at least one character, false otherwise

isdigit
bool isdigit( const std::string & str )

Return true if all characters in the string are digits and there is at least one character, false otherwise.

islower
bool islower( const std::string & str )

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

isspace
bool isspace( const std::string & str )

Return true if there are only whitespace characters in the string and there is at least one character, false otherwise.

istitle
bool istitle( const std::string & str )

Return true if the string is a titlecased string and there is at least one character, i.e. uppercase characters may only follow uncased characters and lowercase characters only cased ones. Return false otherwise.

isupper
bool isupper( const std::string & str )

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

join
std::string join( const std::string & str, const std::vector< std::string > & seq )

Return a string which is the concatenation of the strings in the sequence seq. The separator between elements is the str argument

ljust
std::string ljust( const std::string & str, int width )

Return the string left justified in a string of length width. Padding is done using spaces. The original string is returned if width is less than str.size

lower
std::string ljust( const std::string & str, int width )

Return a copy of the string converted to lowercase.

lstrip
std::string lstrip( const std::string & str, const std::string & chars = "" )

Return a copy of the string with leading characters removed. If chars is omitted or None, whitespace characters are removed. If given and not "", chars must be a string; the characters in the string will be stripped from the beginning of the string this method is called on (argument "str" ).

replace
std::string replace( const std::string & str, const std::string & oldstr, const std::string & newstr, int count = -1)

Return a copy of the string with all occurrences of substring old replaced by new. If the optional argument count is given, only the first count occurrences are replaced.

rfind
int rfind( const std::string & str, const std::string & sub, int start = 0, int end = MAX_32BIT_INT )

Return the highest index in the string where substring sub is found, such that sub is contained within sstart,end. Optional arguments start and end are interpreted as in slice notation. Return -1 on failure.

rindex
int rindex( const std::string & str, const std::string & sub, int start = 0, int end = MAX_32BIT_INT )

Currently a synonym of rfind. The python version raises exceptions. This one currently does not.

rjust
std::string rjust( const std::string & str, int width)

Return the string right justified in a string of length width. Padding is done using spaces. The original string is returned if width is less than str.size()

rsplit
void rsplit( const std::string & str, std::vector< std::string > & result, const std::string & sep = "", int maxsplit = -1)

Fills the "result" list with the words in the string, using sep as the delimiter string. Does a number of splits starting at the end of the string, the result still has the split strings in their original order. If maxsplit is > -1, at most maxsplit splits are done. If sep is "", any whitespace string is a separator.

rstrip
std::string rstrip( const std::string & str, const std::string & chars = "" );

Return a copy of the string with trailing characters removed. If chars is "", whitespace characters are removed. If not "", the characters in the string will be stripped from the end of the string this method is called on.

slice
std::string slice( const std::string & str, int start = 0, int end = MAX_32BIT_INT)

Function matching python's slice functionality.

split
void split( const std::string & str, std::vector< std::string > & result, const std::string & sep = "", int maxsplit = -1)

Fills the "result" list with the words in the string, using sep as the delimiter string. If maxsplit is > -1, at most maxsplit splits are done. If sep is "", any whitespace string is a separator.

splitlines
void splitlines( const std::string & str, std::vector< std::string > & result, bool keepends = false )

Return a list of the lines in the string, breaking at line boundaries. Line breaks are not included in the resulting list unless keepends is given and true.

startswith
bool startswith( const std::string & str, const std::string & prefix, int start = 0, int end = MAX_32BIT_INT )

Return True if string starts with the prefix, otherwise return False. With optional start, test string beginning at that position. With optional end, stop comparing string at that position.

strip
std::string strip( const std::string & str, const std::string & chars = "" )

Return a copy of the string with leading and trailing characters removed. If chars is "", whitespace characters are removed. If given not "", the characters in the string will be stripped from the both ends of the string this method is called on.

swapcase
std::string swapcase( const std::string & str )

Return a copy of the string with uppercase characters converted to lowercase and vice versa.

title
std::string title( const std::string & str )

Return a titlecased version of the string: words start with uppercase characters, all remaining cased characters are lowercase.

translate
std::string translate( const std::string & str, const std::string & table, const std::string & deletechars = "")

Return a copy of the string where all characters occurring in the optional argument deletechars are removed, and the remaining characters have been mapped through the given translation table, which must be a string of length 256.

upper
std::string upper( const std::string & str )

Return a copy of the string converted to uppercase.

zfill
std::string zfill( const std::string & str, int width )

Return the numeric string left filled with zeros in a string of length width. The original string is returned if width is less than str.size().

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录