{"id":24609,"date":"2021-10-23T09:09:39","date_gmt":"2021-10-23T03:39:39","guid":{"rendered":"https:\/\/python-programs.com\/?p=24609"},"modified":"2021-11-05T19:13:08","modified_gmt":"2021-11-05T13:43:08","slug":"python-string-isprintable-method-examples","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-string-isprintable-method-examples\/","title":{"rendered":"Python String isprintable() Method with Examples"},"content":{"rendered":"
In the previous article, we have discussed Python String isidentifier() Method Examples<\/a> Python String isprintable() is a built-in string handling method. If all characters in the string are printable or the string is empty, the isprintable() method returns “True.” Otherwise, it returns “False.” This function determines whether or not the argument contains any printable characters, such as:<\/p>\n Syntax:<\/strong><\/p>\n Parameters: <\/strong>This function has no parameters.<\/p>\n Return Value:<\/strong><\/p>\n This method returns:<\/p>\n Examples:<\/strong><\/p>\n Example1:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Example2:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Are you facing difficulties in finding all the methods that a string object can call in python? Have a glance at this Python String Method Examples<\/a> Tutorial & meet such challenges with ease.<\/p>\n In the previous article, we have discussed Python String isidentifier() Method Examples isprintable() Method in Python: Python String isprintable() is a built-in string handling method. If all characters in the string are printable or the string is empty, the isprintable() method returns “True.” Otherwise, it returns “False.” This function determines whether or not the argument …<\/p>\n
\nisprintable() Method in Python:<\/strong><\/p>\n\n
string.isprintable()<\/pre>\n
\n
Given string = 'Welcome to Python-programs'\r\nGiven string = 'hello this is\\n btechgeeks'\r\nGiven string = ' '<\/pre>\n
The given string = Welcome to Python-programs\r\nChecking if the given string is printable or not = True\r\nThe given string = hello this is\r\n btechgeeks\r\nChecking if the given string is printable or not = False\r\nThe given string = \r\nChecking if the given string is printable or not = True<\/pre>\n
Given string = '\/n good morning btechgeeks\\n'\r\nGiven string = 'hello this a python platform'\r\nGiven string = '_welcome all_'<\/pre>\n
The given string = \/n good morning btechgeeks\r\n\r\nChecking if the given string is printable or not = False\r\nThe given string = hello this a python platform\r\nChecking if the given string is printable or not = True\r\nThe given string = _welcome all_\r\nChecking if the given string is printable or not = True<\/pre>\n
String isprintable() Method Examples in Python<\/h2>\n
\n
Method #1: Using Built-in Functions (Static Input)<\/h3>\n
\n
# Give the string as static input and store it in a variable.\r\ngvn_strng1 = 'Welcome to Python-programs'\r\n# Apply isprintable() function to the given string in which if all characters\r\n# in the given string are printable or the string is empty,\r\n# the isprintable() method returns \"True.\" Otherwise, it returns \"False.\"\r\n# Store it in another variable.\r\nrslt_1 = gvn_strng1.isprintable()\r\n# Print the above-given String.\r\nprint(\"The given string = \", gvn_strng1)\r\n# Print the result after checking if the given string is printable or not.\r\nprint(\"Checking if the given string is printable or not = \", rslt_1)\r\n# Similarly, do the same for other strings and print the result.\r\ngvn_strng2 = 'hello this is\\n btechgeeks'\r\nrslt_2 = gvn_strng2.isprintable()\r\nprint(\"The given string = \", gvn_strng2)\r\nprint(\"Checking if the given string is printable or not = \", rslt_2)\r\n\r\ngvn_strng3 = ' '\r\nrslt_3 = gvn_strng3.isprintable()\r\nprint(\"The given string = \", gvn_strng3)\r\nprint(\"Checking if the given string is printable or not = \", rslt_3)\r\n<\/pre>\n
The given string = Welcome to Python-programs\r\nChecking if the given string is printable or not = True\r\nThe given string = hello this is\r\n btechgeeks\r\nChecking if the given string is printable or not = False\r\nThe given string = \r\nChecking if the given string is printable or not = True<\/pre>\n
\n