Found 33581 Articles for Programming

Handling Exception and use of CX_ROOT directly and subclasses

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

327 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?

Yaswanth Varma
Updated on 11-Apr-2025 12:04:01

1K+ Views

In this article we are going to check whether the string starts with the substring or not, It is useful for checking whether the string starts with the substring, which is helpful in tasks like filtering data or validating input. In Python there are various ways to perform this check, such as startswith(), string slicing and regular expression. Let's dive into the article to learn more about them. Using python startswith() Method The Python startswith() method is used to check whether the string starts with a given substring or not. This method accepts a prefix string that you ... Read More

How to split at NEWLINEs in Python?

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

32K+ 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?

Yaswanth Varma
Updated on 11-Apr-2025 12:03:31

2K+ Views

While working with the strings in python, we will find the situations to break the string into parts. This is called splitting a string and is usually done based on a delimiter, this is nothing but a character or sequence of characters that separate the parts of the string. Python provides the several ways for achieving this, depending on whether the delimiter is simple string or a pattern. Let's dive into the article to learn more about splitting string by delimiter. Using python split() Method The python split() method is used to split the words in a string separated by ... 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?

Yaswanth Varma
Updated on 11-Apr-2025 12:02:11

616 Views

In python, Right-aligning the strings with space padding is a common requirement when formatting the text-based output such as reports, logs or tabular data. This can be done by using the built-in string methods. Let's dive into the article, to learn different ways to get a space-padded string with the original string right-justified in python. Using python rjust() Method The python rjust() method is used to right-align a string by padding it with a specified character on the left. Syntax Following is the syntax of python rjust() method − str.rjust(length, character) Example Let's look at 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

4K+ 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

How to find index of last occurrence of a substring in a string in Python?

Yaswanth Varma
Updated on 11-Apr-2025 12:01:39

15K+ Views

In Python, working with strings is a common task in data processing and text analysis. The common operation is finding the last occurrence of a specific substring. It is useful in situations like extracting the domain names or locating the repeated elements in logs. Python provides several methods to accomplish this; the most commonly used are − Python rfind() Method Python rindex() Method Using python rfind() Method The Python rfind() method is used to find the last occurrence of the substring in the given string; if not found, ... Read More

How to replace all occurrences of a string with another string in Python?

Sarika Singh
Updated on 11-Jun-2025 16:49:42

2K+ Views

In Python, you can replace all occurrences of a substring within a string using the replace() method. This method returns a new string where every occurrence of the given old substring is replaced with a new substring. To match the string with case-insensitivity, you need to use regular expressions. Using the replace() Method The Python replace() method returns a new string where all occurrences of the old substring are replaced with the new substring. It does not modify the original string because strings in Python are immutable. string.replace(oldvalue, newvalue, count) where, ... Read More

Advertisements