String libraries and string methods in Python; dir() function in Python

Publié le: 20 juin 2020
sur la chaîne: Olga Soboleva
45
2

#python #stringmethods #stringlibrary #dirfunction

Exercises:

1. How would you print out the following string in all
lower case in Python?
upper case in Python?

f = 'Gone with the Wind'

2. How would you get rid of the spaces from the left and right sides of the following string?

f = ' Gone with the Wind '

______________________________________________________________________________________

A string library is a bunch of string methods. String methods are a build-in functions that we use to modify strings.

Using a dir() function we can see available string methods. Let's test some of them:

lower()
upper()
capitalize()
startswith()
lstrip()
strip()

Examples:

g = 'Hi John'

ws = ' Hi John '

Python course #2 in English 5
Python programming language course in English

#pythonexercises #pythontasks #python程式設計語言 #python程式設 #程式設計語言 #程式設


Sur cette page du site, vous pouvez voir la vidéo en ligne String libraries and string methods in Python; dir() function in Python durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Olga Soboleva 20 juin 2020, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 45 fois et il a aimé 2 téléspectateurs. Bon visionnage!