{"id":2410,"date":"2023-07-22T09:52:46","date_gmt":"2023-07-22T09:52:46","guid":{"rendered":"https:\/\/statorials.org\/tr\/beklenen-tur-hata-dizesi-veya-nesne-olarak-bayt\/"},"modified":"2023-07-22T09:52:46","modified_gmt":"2023-07-22T09:52:46","slug":"beklenen-tur-hata-dizesi-veya-nesne-olarak-bayt","status":"publish","type":"post","link":"https:\/\/statorials.org\/tr\/beklenen-tur-hata-dizesi-veya-nesne-olarak-bayt\/","title":{"rendered":"Nas\u0131l onar\u0131l\u0131r: t\u00fcr hatas\u0131: beklenen dize veya bayt nesnesi"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Python kullan\u0131rken kar\u015f\u0131la\u015fabilece\u011finiz bir hata:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #ff0000;\">TypeError<\/span> : expected string or bytes-like object\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Bu hata genellikle bir nesnedeki baz\u0131 kal\u0131plar\u0131 de\u011fi\u015ftirmek i\u00e7in <strong>re.sub()<\/strong> i\u015flevini kullanmaya \u00e7al\u0131\u015ft\u0131\u011f\u0131n\u0131zda ancak \u00fczerinde \u00e7al\u0131\u015ft\u0131\u011f\u0131n\u0131z nesnenin tamamen dizelerden olu\u015fmad\u0131\u011f\u0131 durumlarda ortaya \u00e7\u0131kar.<\/span><\/p>\n<p> <span style=\"color: #000000;\">A\u015fa\u011f\u0131daki \u00f6rnekte bu hatan\u0131n pratikte nas\u0131l d\u00fczeltilece\u011fi g\u00f6sterilmektedir.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Hata nas\u0131l yeniden olu\u015fturulur?<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">A\u015fa\u011f\u0131daki de\u011ferler listesine sahip oldu\u011fumuzu varsayal\u0131m:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#define list of values\n<span style=\"color: #000000;\">x = [1, 'A', 2, 'B', 5, 'C', 'D', 'E']\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">\u015eimdi listedeki harf olmayan her \u015feyi bo\u015f bir dizeyle de\u011fi\u015ftirmeye \u00e7al\u0131\u015ft\u0131\u011f\u0131m\u0131z\u0131 varsayal\u0131m:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008000;\">import<\/span> re\n\n<span style=\"color: #008080;\">#attempt to replace each non-letter with empty string<\/span>\nx = re. <span style=\"color: #3366ff;\">sub<\/span> (' <span style=\"color: #ff0000;\">[^a-zA-Z]<\/span> ', '', x)\n\n<span style=\"color: #ff0000;\">TypeError<\/span> : expected string or bytes-like object\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Listedeki baz\u0131 de\u011ferler string olmad\u0131\u011f\u0131 i\u00e7in hata al\u0131yoruz.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Hata nas\u0131l d\u00fczeltilir?<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Bu hatay\u0131 d\u00fczeltmenin en kolay yolu, listeyi <strong>str()<\/strong> operat\u00f6r\u00fcne sararak bir dize nesnesine d\u00f6n\u00fc\u015ft\u00fcrmektir:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008000;\">import<\/span> re\n\n<span style=\"color: #008080;\">#replace each non-letter with empty string\n<\/span>x = re. <span style=\"color: #3366ff;\">sub<\/span> (' <span style=\"color: #ff0000;\">[^a-zA-Z]<\/span> ', '', <span style=\"color: #008000;\">str<\/span> (x))\n\n<span style=\"color: #008080;\">#display results<\/span>\n<span style=\"color: #008000;\">print<\/span> (x)\n\nA B C D E\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Listeyi \u00f6nce bir dize nesnesine d\u00f6n\u00fc\u015ft\u00fcrmek i\u00e7in <strong>str()<\/strong> i\u015flevini kulland\u0131\u011f\u0131m\u0131z i\u00e7in bir hata almad\u0131\u011f\u0131m\u0131z\u0131 unutmay\u0131n.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Sonu\u00e7, harf olmayan her \u015feyin bir bo\u015flukla de\u011fi\u015ftirildi\u011fi orijinal listedir.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Not<\/strong> : <strong>re.sub()<\/strong> i\u015flevine ili\u015fkin t\u00fcm belgeleri <a href=\"https:\/\/docs.python.org\/3\/library\/re.html\" target=\"_blank\" rel=\"noopener\">burada<\/a> bulabilirsiniz.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Ek kaynaklar<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">A\u015fa\u011f\u0131daki e\u011fitimlerde Python&#8217;daki di\u011fer yayg\u0131n hatalar\u0131n nas\u0131l d\u00fczeltilece\u011fi a\u00e7\u0131klanmaktad\u0131r:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/tr\/pandalarin-anahtar-hatasi\/\" target=\"_blank\" rel=\"noopener\">Pandas&#8217;ta KeyError Nas\u0131l D\u00fczeltilir<\/a><br \/> <a href=\"https:\/\/statorials.org\/tr\/deger-hatasi-kayan-noktali-nani-tam-sayiya-donusturemiyor\/\" target=\"_blank\" rel=\"noopener\">Nas\u0131l d\u00fczeltilir? ValueError: float NaN int&#8217;ye d\u00f6n\u00fc\u015ft\u00fcr\u00fclemiyor<\/a><br \/> <a href=\"https:\/\/statorials.org\/tr\/islenenler-formlarla-yayinlanamadi\/\" target=\"_blank\" rel=\"noopener\">Nas\u0131l d\u00fczeltilir? ValueError: \u0130\u015flenenler \u015fekillerle yay\u0131nlanamad\u0131<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python kullan\u0131rken kar\u015f\u0131la\u015fabilece\u011finiz bir hata: TypeError : expected string or bytes-like object Bu hata genellikle bir nesnedeki baz\u0131 kal\u0131plar\u0131 de\u011fi\u015ftirmek i\u00e7in re.sub() i\u015flevini kullanmaya \u00e7al\u0131\u015ft\u0131\u011f\u0131n\u0131zda ancak \u00fczerinde \u00e7al\u0131\u015ft\u0131\u011f\u0131n\u0131z nesnenin tamamen dizelerden olu\u015fmad\u0131\u011f\u0131 durumlarda ortaya \u00e7\u0131kar. A\u015fa\u011f\u0131daki \u00f6rnekte bu hatan\u0131n pratikte nas\u0131l d\u00fczeltilece\u011fi g\u00f6sterilmektedir. Hata nas\u0131l yeniden olu\u015fturulur? A\u015fa\u011f\u0131daki de\u011ferler listesine sahip oldu\u011fumuzu varsayal\u0131m: #define list [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-2410","post","type-post","status-publish","format-standard","hentry","category-rehber"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Nas\u0131l D\u00fczeltilir: T\u00fcr Hatas\u0131: Beklenen Dize veya Bayt Nesnesi - Statoryaller<\/title>\n<meta name=\"description\" content=\"Bu e\u011fitimde Python&#039;da a\u015fa\u011f\u0131daki hatan\u0131n nas\u0131l d\u00fczeltilece\u011fi a\u00e7\u0131klanmaktad\u0131r: Nas\u0131l d\u00fczeltilir: Typeerror: Beklenen dize veya t\u00fcr bayt\u0131 nesnesi.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/statorials.org\/tr\/beklenen-tur-hata-dizesi-veya-nesne-olarak-bayt\/\" \/>\n<meta property=\"og:locale\" content=\"tr_TR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Nas\u0131l D\u00fczeltilir: T\u00fcr Hatas\u0131: Beklenen Dize veya Bayt Nesnesi - Statoryaller\" \/>\n<meta property=\"og:description\" content=\"Bu e\u011fitimde Python&#039;da a\u015fa\u011f\u0131daki hatan\u0131n nas\u0131l d\u00fczeltilece\u011fi a\u00e7\u0131klanmaktad\u0131r: Nas\u0131l d\u00fczeltilir: Typeerror: Beklenen dize veya t\u00fcr bayt\u0131 nesnesi.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/tr\/beklenen-tur-hata-dizesi-veya-nesne-olarak-bayt\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-22T09:52:46+00:00\" \/>\n<meta name=\"author\" content=\"Dr.benjamin anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Yazan:\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dr.benjamin anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tahmini okuma s\u00fcresi\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 dakika\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/tr\/beklenen-tur-hata-dizesi-veya-nesne-olarak-bayt\/\",\"url\":\"https:\/\/statorials.org\/tr\/beklenen-tur-hata-dizesi-veya-nesne-olarak-bayt\/\",\"name\":\"Nas\u0131l D\u00fczeltilir: T\u00fcr Hatas\u0131: Beklenen Dize veya Bayt Nesnesi - Statoryaller\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/tr\/#website\"},\"datePublished\":\"2023-07-22T09:52:46+00:00\",\"dateModified\":\"2023-07-22T09:52:46+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/tr\/#\/schema\/person\/365dc158a39a7c8ae256355451e3de48\"},\"description\":\"Bu e\u011fitimde Python&#39;da a\u015fa\u011f\u0131daki hatan\u0131n nas\u0131l d\u00fczeltilece\u011fi a\u00e7\u0131klanmaktad\u0131r: Nas\u0131l d\u00fczeltilir: Typeerror: Beklenen dize veya t\u00fcr bayt\u0131 nesnesi.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/tr\/beklenen-tur-hata-dizesi-veya-nesne-olarak-bayt\/#breadcrumb\"},\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/tr\/beklenen-tur-hata-dizesi-veya-nesne-olarak-bayt\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/tr\/beklenen-tur-hata-dizesi-veya-nesne-olarak-bayt\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Ev\",\"item\":\"https:\/\/statorials.org\/tr\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Nas\u0131l onar\u0131l\u0131r: t\u00fcr hatas\u0131: beklenen dize veya bayt nesnesi\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/tr\/#website\",\"url\":\"https:\/\/statorials.org\/tr\/\",\"name\":\"Statorials\",\"description\":\"\u0130statistik okuryazarl\u0131\u011f\u0131 rehberiniz!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/tr\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"tr\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/tr\/#\/schema\/person\/365dc158a39a7c8ae256355451e3de48\",\"name\":\"Dr.benjamin anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"tr\",\"@id\":\"https:\/\/statorials.org\/tr\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/tr\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/tr\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Dr.benjamin anderson\"},\"description\":\"Merhaba, ben Benjamin, emekli bir istatistik profes\u00f6r\u00fc ve Statorials \u00f6\u011fretmenine d\u00f6n\u00fc\u015ft\u00fcm. \u0130statistik alan\u0131ndaki kapsaml\u0131 deneyimim ve uzmanl\u0131\u011f\u0131mla, \u00f6\u011frencilerimi Statorials arac\u0131l\u0131\u011f\u0131yla g\u00fc\u00e7lendirmek i\u00e7in bilgilerimi payla\u015fmaya can at\u0131yorum. Daha fazlas\u0131n\u0131 bil\",\"sameAs\":[\"https:\/\/statorials.org\/tr\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Nas\u0131l D\u00fczeltilir: T\u00fcr Hatas\u0131: Beklenen Dize veya Bayt Nesnesi - Statoryaller","description":"Bu e\u011fitimde Python&#39;da a\u015fa\u011f\u0131daki hatan\u0131n nas\u0131l d\u00fczeltilece\u011fi a\u00e7\u0131klanmaktad\u0131r: Nas\u0131l d\u00fczeltilir: Typeerror: Beklenen dize veya t\u00fcr bayt\u0131 nesnesi.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/statorials.org\/tr\/beklenen-tur-hata-dizesi-veya-nesne-olarak-bayt\/","og_locale":"tr_TR","og_type":"article","og_title":"Nas\u0131l D\u00fczeltilir: T\u00fcr Hatas\u0131: Beklenen Dize veya Bayt Nesnesi - Statoryaller","og_description":"Bu e\u011fitimde Python&#39;da a\u015fa\u011f\u0131daki hatan\u0131n nas\u0131l d\u00fczeltilece\u011fi a\u00e7\u0131klanmaktad\u0131r: Nas\u0131l d\u00fczeltilir: Typeerror: Beklenen dize veya t\u00fcr bayt\u0131 nesnesi.","og_url":"https:\/\/statorials.org\/tr\/beklenen-tur-hata-dizesi-veya-nesne-olarak-bayt\/","og_site_name":"Statorials","article_published_time":"2023-07-22T09:52:46+00:00","author":"Dr.benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Yazan:":"Dr.benjamin anderson","Tahmini okuma s\u00fcresi":"1 dakika"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/tr\/beklenen-tur-hata-dizesi-veya-nesne-olarak-bayt\/","url":"https:\/\/statorials.org\/tr\/beklenen-tur-hata-dizesi-veya-nesne-olarak-bayt\/","name":"Nas\u0131l D\u00fczeltilir: T\u00fcr Hatas\u0131: Beklenen Dize veya Bayt Nesnesi - Statoryaller","isPartOf":{"@id":"https:\/\/statorials.org\/tr\/#website"},"datePublished":"2023-07-22T09:52:46+00:00","dateModified":"2023-07-22T09:52:46+00:00","author":{"@id":"https:\/\/statorials.org\/tr\/#\/schema\/person\/365dc158a39a7c8ae256355451e3de48"},"description":"Bu e\u011fitimde Python&#39;da a\u015fa\u011f\u0131daki hatan\u0131n nas\u0131l d\u00fczeltilece\u011fi a\u00e7\u0131klanmaktad\u0131r: Nas\u0131l d\u00fczeltilir: Typeerror: Beklenen dize veya t\u00fcr bayt\u0131 nesnesi.","breadcrumb":{"@id":"https:\/\/statorials.org\/tr\/beklenen-tur-hata-dizesi-veya-nesne-olarak-bayt\/#breadcrumb"},"inLanguage":"tr","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/tr\/beklenen-tur-hata-dizesi-veya-nesne-olarak-bayt\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/tr\/beklenen-tur-hata-dizesi-veya-nesne-olarak-bayt\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Ev","item":"https:\/\/statorials.org\/tr\/"},{"@type":"ListItem","position":2,"name":"Nas\u0131l onar\u0131l\u0131r: t\u00fcr hatas\u0131: beklenen dize veya bayt nesnesi"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/tr\/#website","url":"https:\/\/statorials.org\/tr\/","name":"Statorials","description":"\u0130statistik okuryazarl\u0131\u011f\u0131 rehberiniz!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/tr\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"tr"},{"@type":"Person","@id":"https:\/\/statorials.org\/tr\/#\/schema\/person\/365dc158a39a7c8ae256355451e3de48","name":"Dr.benjamin anderson","image":{"@type":"ImageObject","inLanguage":"tr","@id":"https:\/\/statorials.org\/tr\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/tr\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/tr\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Dr.benjamin anderson"},"description":"Merhaba, ben Benjamin, emekli bir istatistik profes\u00f6r\u00fc ve Statorials \u00f6\u011fretmenine d\u00f6n\u00fc\u015ft\u00fcm. \u0130statistik alan\u0131ndaki kapsaml\u0131 deneyimim ve uzmanl\u0131\u011f\u0131mla, \u00f6\u011frencilerimi Statorials arac\u0131l\u0131\u011f\u0131yla g\u00fc\u00e7lendirmek i\u00e7in bilgilerimi payla\u015fmaya can at\u0131yorum. Daha fazlas\u0131n\u0131 bil","sameAs":["https:\/\/statorials.org\/tr"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/tr\/wp-json\/wp\/v2\/posts\/2410","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/statorials.org\/tr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/tr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/tr\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/tr\/wp-json\/wp\/v2\/comments?post=2410"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/tr\/wp-json\/wp\/v2\/posts\/2410\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/tr\/wp-json\/wp\/v2\/media?parent=2410"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/tr\/wp-json\/wp\/v2\/categories?post=2410"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/tr\/wp-json\/wp\/v2\/tags?post=2410"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}