Ministério da Educação
Brasil um país de todos
Personal tools
Navigation
Log in


Forgot your password?
 
Document Actions

shell-strings.py

by Cicero Garrozi last modified 2014-05-06 07:13

Click here to get the file

Size 1.1 kB - File type text/python-source

File contents

Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> s = "Ola pessoal de IP"
>>> s[:]
'Ola pessoal de IP'
>>> s.startswith("ola")
False
>>> s.startswith("Ola")
True
>>> len(s)
17
>>> s[:len(s)]
'Ola pessoal de IP'
>>> s[:len(s)-1]
'Ola pessoal de I'
>>> s[len(s)-1]
'P'
>>> s[:-1]
'Ola pessoal de I'
>>> s[-1]
'P'
>>> s[:-1]+s[-1]
'Ola pessoal de IP'
>>> cont = 0
>>> for letra in s:
	if letra == ' ':
		cont += 1

>>> cont
3
>>> s
'Ola pessoal de IP'
>>> s.upper()
'OLA PESSOAL DE IP'
>>> s
'Ola pessoal de IP'
>>> s.lower()
'ola pessoal de ip'
>>> s
'Ola pessoal de IP'
>>> s.count(' ')
3
>>> s.count('a')
2
>>> s.count('A')
0
>>> s.count("ss")
1
>>> s.count("pes")
1
>>> s.lower().count("o")
2
>>> s
'Ola pessoal de IP'
>>> s = s.lower()
>>> s
'ola pessoal de ip'
>>> s
'ola pessoal de ip'
>>> s.replace('i', 'I')
'ola pessoal de Ip'
>>> s
'ola pessoal de ip'
>>> print "Alô" "Mundo"
AlôMundo
>>> print "Alô"+"Mundo"
AlôMundo
>>> print "Alô!"*2+"Mundo"
Alô!Alô!Mundo
>>> 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: