{"id":2987,"date":"2023-10-19T09:44:45","date_gmt":"2023-10-19T04:14:45","guid":{"rendered":"https:\/\/python-programs.com\/?p=2987"},"modified":"2023-11-10T11:48:32","modified_gmt":"2023-11-10T06:18:32","slug":"basics-of-python-string-constants","status":"publish","type":"post","link":"https:\/\/python-programs.com\/basics-of-python-string-constants\/","title":{"rendered":"Basics of Python \u2013 String Constants"},"content":{"rendered":"

In this Page, We are Providing Basics of Python \u2013 String Constants. Students can visit for more Detail and Explanation of Python Handwritten Notes<\/a>\u00a0Pdf.<\/p>\n

Basics of Python \u2013 String Constants<\/h2>\n

String constants<\/strong><\/p>\n

Some constants defined in the string module are as follows:<\/p>\n

string. ascii_lowercase
\nIt returns a string containing the lowercase letters ‘ abcdefghijklmnopqrstuvwxyz ‘.<\/p>\n

>>> import string\r\n>>> string . ascii_lowercase\r\n' abcdefghijklmnopqrstuvwxyz '<\/pre>\n

string. ascii_uppercase
\nIt returns a string containing uppercase letters ‘ ABCDEFGHIJKLMNOPQRSTUVWXYZ ‘.<\/p>\n

>>> string . ascii_uppercase \r\n' ABCDEFGHIJKLMNOPQRSTUVWXYZ '<\/pre>\n

string. ascii_letters
\nIt returns a string containing the concatenation of the ascii_lowercase and ascii_uppercase constants.<\/p>\n

>>> string . ascii_letters\r\n' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '<\/pre>\n

string. digits
\nIt returns the string containing the digits ‘ 0123456789 ‘.<\/p>\n

>>> string.digits \r\n' 0123456789 '<\/pre>\n

String.hex digits
\nIt returns the string containing hexadecimal characters ‘ 0123456789abcdef ABCDEF ‘.<\/p>\n

>>> string.hexdigits \r\n' 0123456789abcdef ABCDEF \u2019<\/pre>\n

string.octdigits
\nIt returns the string containing octal characters ‘ 01234567 ‘.<\/p>\n

>>> string.octdigits \r\n' 01234567 '<\/pre>\n

string. punctuation
\nIt returns the string of ASCII characters which are considered punctuation characters.<\/p>\n

>>> string.punctuation
\n‘ ! ” # $ % & \\ ‘ ( ) * + , – . \/ : ; <=> ? @ [ \\\\ ] \u2227 _ ‘ { | } \u223c ‘<\/p>\n

string. whitespace
\nIt returns the string containing all characters that are considered whitespace like space, tab, vertical tab, etc.<\/p>\n

>>> string.whitespace
\n‘ \\ t \\ n \\ x0b \\ x0c \\ r ‘<\/p>\n

string. printable
\nIt returns the string of characters that are considered printable. This is a combination of digits, letters, punctuation, and whitespace.<\/p>\n

>>> string . printable\r\n' 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ! \" # $ % & \\ ' ( ) * + , - . \/ : ; <=> ? 0 [ \\\\ ]\u2227 _ ' { I \\ t \\ n \\ r \\ x0b \\ x0c\u00a0 '<\/pre>\n

Python String Programs<\/h3>\n