1 / 13

Las cadenas 3 Día 5, 24 ene 14

Las cadenas 3 Día 5, 24 ene 14. Cultura computacional en español SPAN 4350 Harry Howard Tulane University. Organizaci ón del curso. Las grabaciones y las presentaciones están disponibles en: http://www.tulane.edu/~howard/SPAN-NLP/

Télécharger la présentation

Las cadenas 3 Día 5, 24 ene 14

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Las cadenas 3Día 5, 24 ene 14 Cultura computacional en español SPAN 4350 Harry Howard Tulane University

  2. Organización del curso • Las grabaciones y las presentaciones están disponibles en:http://www.tulane.edu/~howard/SPAN-NLP/ • La versión en inglés del tema es http://www.tulane.edu/~howard/CompCultES/strings.html SPAN 4350 - Harry Howard - Tulane University

  3. Repaso SPAN 4350 - Harry Howard - Tulane University

  4. Métodos C = 'otolaringologo' >>> len(C) >>> sorted(C) >>> set(C) >>> C+'!' >>> C*2 >>> C.count('o') >>> C.index('o') >>> C.rindex('o') >>> C.find('o') >>> C.rfind('o') >>> C.lower() >>> C.upper() >>> C.swapcase() >>> C.capitalize() >>> C.title() >>> C.replace('t','m') >>> C.strip('o') SPAN 4350 - Harry Howard - Tulane University

  5. Un diagrama de la indezación SPAN 4350 - Harry Howard - Tulane University

  6. Sintaxis • atributo.metodo(argumento) • find/index(cadena, principio, fin) • cadena[principio:fin] SPAN 4350 - Harry Howard - Tulane University

  7. Abran Python. cadenas SPAN 4350 - Harry Howard - Tulane University

  8. ¿Cuál es la diferencia entre find() y index()? >>> C.find('otto') -1 >>> C.index('otto') Traceback (mostrecentcalllast): File "<stdin>", line 1, in <module> ValueError: substring not found SPAN 4350 - Harry Howard - Tulane University

  9. El corte extendido >>> CC = 'ABCDEFGH' >>> CC[::1] >>> CC[::2] >>> CC[::3] >>> CC[::4] >>> CC[1:7:1] >>> CC[1:7:2] >>> CC[1:7:3] >>> CC[1:7:6] cadena[principio:fin:paso] SPAN 4350 - Harry Howard - Tulane University

  10. Poner una cadena al revés >>> CC[::-1] >>> CC[::-2] >>> CC[::-3] >>> CC[::-4] SPAN 4350 - Harry Howard - Tulane University

  11. Todas son cadenas >>> C = 'ABCDEFGH' >>> c = 'abcdefgh' >>> C[:3].lower() >>> c[:3].upper() >>> C[:3].capitalize() >>> C[:3].capitalize().upper() >>> c[:3].capitalize().lower() >>> (c[:4].upper()+C[4:].lower()).swapcase() SPAN 4350 - Harry Howard - Tulane University

  12. Práctica • C = 'abcdefg' • Conviertan C en 'ABCD'. • C[:4].upper() • Conviertan C en 'abWXYfg'. • C.replace('cde','WXY') • Conviertan C en 'HgFeDcBa'. • 'H'+C.replace(C,'aBcDeFg')[::-1] SPAN 4350 - Harry Howard - Tulane University

  13. P1 como tarea en casa: se lo voy a mandar por correo electrónico. Terminar cadenas y empezar Unicode. El próximo díaTráete el portátil a clase. SPAN 4350 - Harry Howard - Tulane University

More Related