{"id":37998,"date":"2016-10-13T12:45:26","date_gmt":"2016-10-13T17:45:26","guid":{"rendered":"http:\/\/miketrianablog.wordpress.com\/?p=318"},"modified":"2016-10-13T12:45:26","modified_gmt":"2016-10-13T17:45:26","slug":"strings-una-gran-cadena","status":"publish","type":"post","link":"https:\/\/kenscourses.com\/tc101fall2016\/syndicated\/strings-una-gran-cadena\/","title":{"rendered":"Strings, una gran cadena"},"content":{"rendered":"<p class=\"syndicated-attribution\"><em> --Originally published at <a href=\"https:\/\/miketrianablog.wordpress.com\/2016\/10\/13\/strings-una-gran-cadena\/\"><a href=\"https:\/\/miketrianablog.wordpress.com\">Mike&amp;#039;s Blog<\/a><\/a><\/em><br \/><\/p>\n<p>Como ya hemos visto los strings son cualquier valor de texto asignado a una variable. Este valor es inmutable, y como su nombre lo dice, es una cadena de caracteres. Estos valores se pueden escribir de diferentes maneras, siendo la m\u00e1s famosa las comillas (&#8221; &#8220;). Lo que sea que se encuentre entre las comillas, ser\u00e1 un string.<\/p>\n<p><img class=\"alignnone size-full wp-image-341\" src=\"https:\/\/miketrianablog.files.wordpress.com\/2016\/10\/t3_1wrjjx.gif?w=662\" alt=\"t3_1wrjjx\"   \/><\/p>\n<p>Los strings sirven para almacenar cualquier caracter, ya se para imprimirlo, o solo guardarlo. Algo que hay que tener en cuenta cuando usamos strings, es que son operables, pero no al grado de los n\u00fameros. Si se tiene un valor numerico guardado como string, no lo vamos a poder operar o comparar. Tambi\u00e9n cabe mencionar que si tenemos un n\u00famero integer o float, necesitamos convertirlo a string para poderlo imprimir.\u00a0 El comando para convertir a string es str().<\/p>\n<p>Cuando se tiene un string este no se puede modificar, pero si se puede reemplazar.<\/p>\n<p>Los strings se pueden operar de la siguiente manera:<\/p>\n<table class=\"table table-bordered\">\n<tbody>\n<tr>\n<th>Operator<\/th>\n<th>Description<\/th>\n<th>Example<\/th>\n<\/tr>\n<tr>\n<td>+<\/td>\n<td>Concatenation &#8211; Adds values on either side of the operator<\/td>\n<td>a + b will give HelloPython<\/td>\n<\/tr>\n<tr>\n<td>*<\/td>\n<td>Repetition &#8211; Creates new strings, concatenating multiple copies of the same string<\/td>\n<td>a*2 will give -HelloHello<\/td>\n<\/tr>\n<tr>\n<td>[]<\/td>\n<td>Slice &#8211; Gives the character from the given index<\/td>\n<td>a[1] will give e<\/td>\n<\/tr>\n<tr>\n<td>[ : ]<\/td>\n<td>Range Slice &#8211; Gives the characters from the given range<\/td>\n<td>a[1:4] will give ell<\/td>\n<\/tr>\n<tr>\n<td>in<\/td>\n<td>Membership &#8211; Returns true if a character exists in the given string<\/td>\n<td>H in a will give 1<\/td>\n<\/tr>\n<tr>\n<td>not in<\/td>\n<td>Membership &#8211; Returns true if a character does not exist in the given string<\/td>\n<td>M not in a will give 1<\/td>\n<\/tr>\n<tr>\n<td>r\/R<\/td>\n<td>Raw String &#8211; Suppresses actual meaning of Escape characters. The syntax for raw strings is exactly the same as for normal strings with the exception of the raw <div class=\"post-limited-image\"><img class=\" size-full wp-image-344 aligncenter\" src=\"https:\/\/miketrianablog.files.wordpress.com\/2016\/10\/fig4-1.jpg?w=662\" alt=\"fig4-1\"   \/><\/div>\n<div class=\"post-limited-image\"><img alt=\"\" border=\"0\" src=\"http:\/\/feeds.wordpress.com\/1.0\/comments\/miketrianablog.wordpress.com\/318\/\" \/><\/div>\n<div class=\"post-limited-image\"><img alt=\"\" border=\"0\" src=\"https:\/\/pixel.wp.com\/b.gif?host=miketrianablog.wordpress.com&#038;blog=115237775&%23038;post=318&%23038;subd=miketrianablog&%23038;ref=&%23038;feed=1\" width=\"1\" height=\"1\" \/><\/div><!--more--> operator, the letter &#8220;r,&#8221; which precedes the quotation marks. The &#8220;r&#8221; can be lowercase (r) or uppercase (R) and must be placed immediately preceding the first quote mark.<\/td>\n<td>print r&#8217;\\n&#8217; prints \\n and print R&#8217;\\n&#8217;prints \\n<\/td>\n<\/tr>\n<tr>\n<td>%<\/td>\n<td>Format &#8211; Performs String formatting<\/td>\n<td>See at next section<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Tabla obtenida de: <a href=\"https:\/\/www.tutorialspoint.com\/python3\/python_strings.htm\" rel=\"nofollow\">https:\/\/www.tutorialspoint.com\/python3\/python_strings.htm<\/a><\/p>\n<p>Una cosa muy importante en Python, es que este es sensible a la capitalizaci\u00f3n, lo que significa que si compramos dos strings, y var\u00edan en la capitalizaci\u00f3n, no ser\u00e1n los mismos. Por esto siempre hay que cerciorarnos de que las letras coincidan en la totalidad.<\/p>\n<p>Para esto python es capaz de manipular los strings, por ejemplo para poner en min\u00fasculas se utiliza el comando variable.lower(), y para hacerlas mayusculas variable.upper().<\/p>\n<p><img class=\" size-full wp-image-344 aligncenter\" src=\"https:\/\/miketrianablog.files.wordpress.com\/2016\/10\/fig4-1.jpg?w=662\" alt=\"fig4-1\"   \/><\/p>\n<p>Para ver todas las manipulaciones pueden entrar a:<\/p>\n<p><a href=\"https:\/\/www.tutorialspoint.com\/python3\/python_strings.htm\" rel=\"nofollow\">https:\/\/www.tutorialspoint.com\/python3\/python_strings.htm<\/a><\/p>\n<p><a href=\"https:\/\/docs.python.org\/3\/library\/string.html\" rel=\"nofollow\">https:\/\/docs.python.org\/3\/library\/string.html<\/a><\/p>\n<div class=\"jetpack-video-wrapper\"><iframe class='youtube-player' type='text\/html' width='662' height='403' src='https:\/\/www.youtube.com\/embed\/pqmhZcPpTys?version=3&#038;rel=1&%23038;fs=1&%23038;autohide=2&%23038;showsearch=0&%23038;showinfo=1&%23038;iv_load_policy=1&%23038;wmode=transparent' allowfullscreen='true' style='border:0;'><\/iframe><\/div><br \/>  <a rel=\"nofollow\" href=\"http:\/\/feeds.wordpress.com\/1.0\/gocomments\/miketrianablog.wordpress.com\/318\/\"><img alt=\"\" border=\"0\" src=\"http:\/\/feeds.wordpress.com\/1.0\/comments\/miketrianablog.wordpress.com\/318\/\" \/><\/a> <img alt=\"\" border=\"0\" src=\"https:\/\/pixel.wp.com\/b.gif?host=miketrianablog.wordpress.com&#038;blog=115237775&%23038;post=318&%23038;subd=miketrianablog&%23038;ref=&%23038;feed=1\" width=\"1\" height=\"1\" \/>","protected":false},"excerpt":{"rendered":"<p>&#8211;Originally published at Mike&amp;#039;s Blog Como ya hemos visto los strings son cualquier valor de texto asignado a una variable. Este valor es inmutable, y como su nombre lo dice, es una cadena de caracteres. Estos valores se pueden escribir de diferentes maneras, siendo la m\u00e1s famosa las comillas (&#8221; &#8220;). Lo que sea que &hellip; <a href=\"https:\/\/kenscourses.com\/tc101fall2016\/syndicated\/strings-una-gran-cadena\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Strings, una gran cadena<\/span><\/a><\/p>\n","protected":false},"author":15,"featured_media":341,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[26],"class_list":["post-37998","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blogs","category-syndicated","tag-sin-categoria"],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/37998","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/comments?post=37998"}],"version-history":[{"count":19,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/37998\/revisions"}],"predecessor-version":[{"id":43061,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/37998\/revisions\/43061"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/media?parent=37998"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/categories?post=37998"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/tags?post=37998"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}