Found 34494 Articles for Programming

How to Convert Lowercase Letters in String to Uppercase in Python?

Rajendra Dharmkar
Updated on 10-Aug-2023 19:10:52

1K+ Views

In Python, a string is a sequence of characters. It's a type of data that represents text values, such as words, sentences, or even entire documents. Strings in Python are enclosed in either single quotes ('...') or double quotes ("..."), and can include alphanumeric characters, symbols, whitespace, and more. We can perform various operations on strings, such as concatenation, slicing, and formatting. We can also use various built-in methods to manipulate and transform strings, such as converting them to uppercase or lowercase, splitting them into lists, and replacing substrings. In this article we are considering some examples of converting ... Read More

How to invert case for all letters in a string in Python?

Tarun Chandra
Updated on 19-Oct-2022 12:02:47

2K+ Views

A string is a group of characters that can represent a single word or a complete sentence. In Python there is no need to declare variables explicitly using the datatype specifier you can directly assign them to a literal. Therefore, compared to other technologies like Java it is easy to use Python strings. For manipulating and accessing strings, Python includes several built in functions and methods. You can find these functions in a class named String. In this article, we are going to focus on how to invert the case for all letters in a string in Python. Using the ... Read More

Handling Exception and use of CX_ROOT directly and subclasses

Sai Nath
Updated on 14-Feb-2020 05:37:06

199 Views

It is not advisable to use CX_ROOT directly and you would require using one of its direct subclasses. Also, the propagation depends upon the exception subclass hierarchy.Subclasses of CX_STATIC_CHECK – these do not propagate automatically. You will need to do the handling yourself or there will be a syntax error in the program.Subclasses of CX_DYNAMIC_CHECK – these do not require any handling. But the program that does not handle the exception will be aborted with these subclasses.Subclasses of CX_NO_CHECK – These will get propagated automatically if the exception is not handled.

How to check if string or a substring of string starts with substring in Python?

Tarun Chandra
Updated on 07-Dec-2022 07:44:24

1K+ Views

In this article, we are going to find out how to check if a string or a substring of a string starts with a substring in Python. The first approach is by using the inbuilt method startswith(). This method is used with a string, and we have to give the substring that we want to match as the parameter. Start and end are the two required parameters. Searching begins from the start index, which is called Start, and ends at the end index, which is called End. It returns True if the given string is started with that substring, otherwise ... Read More

How to split at NEWLINEs in Python?

Tarun Chandra
Updated on 07-Dec-2022 07:31:08

27K+ Views

In this article, we are going to find out how to split at newlines in Python. In general, split means to divide or to make a group of objects divide into smaller groups. The first approach to split at NEWLINES in python is by using the inbuilt method splitlines(). It takes a multi-line string as input and it returns a separated string that is divided at the new line. It doesn’t take any parameters. The splitlines() method is an inbuilt string method and it is used only for splitting at the new lines. Example 1 In the program given below, ... Read More

How to split string by a delimiter string in Python?

Tarun Chandra
Updated on 19-Oct-2022 09:05:16

2K+ Views

A string is a collection of characters that can represent a single word or a complete phrase. Unlike Java there is no need to declare Python strings explicitly we can directly assign string value to a literal. A string is an object of the String class, which contains multiple built in functions and methods to manipulate and access strings. In this article, we are going to find out how to split a string by a delimiter string in Python. Using the split() method One way split a string using a delimiter using the string class inbuilt method named split(). This ... Read More

How to remove all trailing whitespace of string in Python?

Rajendra Dharmkar
Updated on 02-May-2023 12:33:55

4K+ Views

Any character or group of characters that depicts horizontal or vertical space is known as whitespace. A whitespace character usually takes up space on a page even though it does not correspond to any visible mark when it is rendered. Pressing the spacebar will allow you to enter a whitespace character. On many keyboards, the Tab key can also be used to enter horizontal whitespace, although the length of the space may vary. Any spaces or tabs that follow the final non-whitespace character on the line until the newline are considered trailing whitespace. Whitespace in Python Whitespace is a type ... Read More

How to get a space-padded string with the original string right-justified in Python?

Tarun Chandra
Updated on 19-Oct-2022 08:50:16

503 Views

A string is a collection of characters that can represent a single word or a complete phrase. We can declare a string or any other datatype in python without the datatype specifier. Therefore, it is easy to use strings in Python compared to Java. A string in Python is represented by the class named String. This class provides several functions and methods using which you can perform various operations on strings. In this article, we are going to focus on how to get a space padded string with the original string right justified in python. Using the rjust() method The ... Read More

Using SAP JCO to connect SAP server to JAVA application

Prabhas
Updated on 25-Jun-2020 21:09:32

2K+ Views

I would suggest you to use below instead of JCO_AHOST and JCO_SYSNR:Use JCO_R3NAME with system ID of the target hostUse JCO_MSHOST with message server host name or IP addressUse JCO_MSSERV with message server port numberUse JCO_GROUP with the name of the logon groupYou can refer to below link to check a working example:https://sourceforge.net/p/rcer/git/ci/master/tree/net.sf.rcer.conn

How to search a string in backwards direction in Python?

Tarun Chandra
Updated on 07-Dec-2022 07:05:30

3K+ Views

In this article, we are going to find out how to search a string in backward direction in Python. The first method is to use the inbuilt python String class's rindex() method. The highest index of any substring in the given string is returned by the Python string rindex() method. By highest index, we mean that if a given substring appears twice or three times in a string, the rindex() method will return the index of the substring's rightmost or final occurrence. The main disadvantage of this function is that it throws an exception if the string contains no substrings. ... Read More

Advertisements