Mega Code Archive
Search
.Net
ASP .Net
ASP .Net Tutorial
C#
C# Book
C# by API
C# Tutorial
VB.Net
VB.Net by API
VB.Net Tutorial
Visual C++ .Net
VisualBasic Script
Java
Java
Java Book
Java by API
Java Tutorial
Script
Flash ActionScript
Flex
JavaScript DHTML
JavaScript Reference
JavaScript Tutorial
Database
MSSQL
MSSQL Tutorial
MySQL
MySQL Tutorial
Oracle PLSQL
Oracle PLSQL Tutorial
PostgreSQL
Languages
Android
C
C Tutorial
C++
C++ Tutorial
Delphi
Perl
PHP
Python
Python Tutorial
Ruby
Silverlight
Office
MSOfficeExcel 2007 Tutorial
MSOfficePowerPoint 2007 Tutorial
MSOfficeWord 2007 Tutorial
Data
XML
XML Tutorial
Python Tutorial
String 114 codes
Home
Python Tutorial
String
1 %[(name)][flags][width][ precision]code
2 A basic conversion specifier
3 A blank ( ) means that a blank should be put in front of positive numbers
4 A minus sign (-) left-aligns the value
5 A plus (+) means that a sign should precede both positive and negative numbers
6 Add backslash to the end of raw string
7 An optional second argument can be supplied to translate, specifying letters that should be deleted
8 Case In-Sensitive Compare
9 Case Sensitive Compare
10 Center a string
11 Cmp() function performs a lexicographic (ASCII value-based) comparison for strings
12 Compare string demo
13 Concatenating Strings
14 Conditional Execution and the if Statement
15 Convert a list of characters back to a string
16 Convert all names to lowercase both when storing and searching
17 Creating strings and using quote characters in strings
18 Dictionary-Based String Formatting
19 Display a string with triple quotes
20 Effects of Setting the Default Encoding
21 Encode(iso-8859-1)
22 Encode(utf-16)
23 Encode(utf-8)
24 Find from an index
25 Find from right
26 Find the index of a substring
27 For any ranges [start
28 For statement Used with Sequence Types
29 For strings, it is easy to iterate over each character
30 Format Operator Auxiliary Directives
31 Formatted String
32 Get the final index of our string is
33 Get the length of an input string
34 How to Access Values (Characters and Substrings) in Strings
35 How to Remove Characters and Strings
36 How to Update Strings
37 ID Check
38 If the replacement field is part of a word, the name must be enclosed in braces
39 In
40 In is case sensitive
41 In order to insert a dollar sign, use $$
42 Index from right
43 Index with offset
44 Interpolating Variables Inside Strings
45 Introducing ljust
46 Introducing StringIO
47 Joining a list of words
48 Joining Strings
49 Left justify
50 Measure some strings
51 Membership (in, not in)
52 Normal to Unicode
53 Print paired with the string format operator ( % )
54 Range() with len() for indexing into a string
55 Raw string
56 Raw Strings dont treat the backslash as a special character
57 Replacing a substring
58 Repr creates a string that is a representation of the value as a legal Python expression
59 Right justify
60 Rindex with index
61 Runtime String Concatenation
62 Search and Replace in Strings
63 Searching from end of string
64 Searching strings for a substring
65 Searching Strings for Specific EndingsBeginnings
66 Searching Strings for Substrings
67 Signs, Alignment, and Zero-Padding
68 Single-Quoted Strings and Escaping Quotes
69 Slice a string
70 Specify which characters are to be stripped, by listing them all in a string parameter
71 Split by
72 Split is the inverse of join, and is used to split a string into a sequence
73 Split lines
74 Split Without Arguments
75 Splitting Strings
76 Storing Non-ASCII Characters
77 Str converts a value into a string
78 String format
79 String formatting
80 String Formatting Conversion Types
81 String formatting is done with the string formatting operator, the percent (%) sign
82 String Formatting vs Concatenating
83 String literals and other sequence literals may be indexed directly, without using a variable to refer to them
84 String variable
85 String-formatting codes
86 Strings are compared according to their order when sorted alphabetically
87 Strip leading and trailing characters
88 Strip tabs
89 Strip trailing spaces
90 Stripping whitespace from a string
91 Take a string and display it in a loop
92 Template strings
93 Template systems (in this case using HTML)
94 The %e, %f, and %g formats display floating-point numbers in different ways, as the following interaction demonstrates
95 The find method finds a substring within a larger string
96 The lower method returns a lowercase version of the string
97 The replace method returns a string where all the occurrences of one string have been replaced by another
98 The strip method returns a string where whitespace on the left and right (but not internally) has been stripped (removed)
99 The syntax for using the format operator is as follows
100 To check whether a value can be found in a sequence, you use the in operator
101 To clear or remove a string, you assign an empty string or use the del statement, respectively
102 To ignore the difference between uppercase and lowercase letters, use the string methods upper or lower
103 To write a string that spans several lines, you can use triple quotes instead of ordinary quotes
104 Token splitting and delimiter joining
105 Translate replaces parts of a string, translate only works with single characters
106 Triple Quotes
107 Unicode Strings
108 Unicode to normal
109 Use the string format operator ( % ), or put all of the substrings in a list, and using one join() call to put them all together.tx
110 Useful Values from the string Module
111 Using None as an index has the same effect as a missing index
112 When either a starting or an ending index is missing, they default to the beginning or end of the string, respectively
113 Width and Precision
114 You can supply the value-name pairs in a dictionary