From the course: Learning ArcGIS Python Scripting
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
String methods and functions - ArcGIS Pro Tutorial
From the course: Learning ArcGIS Python Scripting
String methods and functions
- [Instructor] There are over 40 Python string methods and functions included with the Python language. Before you even add any additional libraries, these functions and methods help us to manipulate string values. For example, the replace method replaces a portion of a string with a different bit of text. Let's see how we would use this in code. If I create a variable called strRockType and I set it equal to Sandstone, that's fine. If I print it right now, it's just going to say Sandstone, but watch how I would use the replace method on this string variable. With these methods, if there's any information needed to tell the method how to work, that information is passed in as a parameter inside the parentheses for that method. So you can see here, I'm using the replace method on the strRockType variable, and I'm replacing the word Sand with the word Lime. So when I run the script, it prints Limestone instead of Sandstone. So that's string manipulation using methods. There are, as I…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.