添加链接
注册
登录
link管理
链接快照平台
输入网页链接,自动生成快照
标签化管理网页链接
相关文章推荐
老实的打火机
·
沈阳地铁九号线东延线要开建了,北延线还有戏吗?
·
4 月前
·
很拉风的西红柿
·
《世界设计现代史》人物篇——现代设计之父威廉 ...
·
5 月前
·
酷酷的熊猫
·
appium uiautomator ...
·
6 月前
·
大鼻子的煎鸡蛋
·
【第736篇】i社游中国官网app最新正版_ ...
·
6 月前
·
寂寞的杯子
·
64线混合固态激光雷达 CB64S1
·
10 月前
·
link管理
›
How to convert Python string to bytes? | Flexiple Tutorials | Python - Flexiple
https://flexiple.com/python/python-string-to-bytes
冷静的山羊
5 月前
</noscript><div style="position:fixed;z-index:9999;top:16px;left:16px;right:16px;bottom:16px;pointer-events:none"/><header class="z-40 hidden transition duration-300 lg:block dark:has-[:hover]:bg-dGrey1 relative"><div class="container mx-auto flex h-16 w-full max-w-7xl items-stretch gap-10 px-4"><div class="logo grid place-items-center"><a aria-label="Flexiple Homepage" href="/"><img role="img" alt="Flexiple Logo" title="Flexiple Logo - Click to visit homepage" aria-label="Flexiple Homepage" loading="lazy" width="110" height="110" decoding="async" data-nimg="1" class="dark:invert" style="color:transparent" src="/_next/static/media/logo.59102633.svg"/></a></div><nav class="flex h-full flex-1 items-center justify-between gap-10 text-base"><div class="flex h-full flex-1 gap-10 px-5"><div class="group/dropdown flex h-full items-center rounded-sm border-b-2 border-white border-opacity-0 transition duration-300 hover:border-opacity-100"><button class="flex cursor-pointer items-center gap-2.5"><span class="__className_587f35 text-xs md:text-base opacity-80">For Companies</span><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-chevron-down transition-transform duration-300 group-hover/dropdown:rotate-180"><path d="m6 9 6 6 6-6"/></svg></button><div class="nav-dropdown absolute left-0 right-0 top-16 z-30 hidden bg-white px-20 py-12 shadow-md group-hover/dropdown:block group-focus/dropdown:block dark:bg-[#222222]"><div class="container mx-auto max-w-7xl"><button type="button" aria-hidden="true" style="position:fixed;top:1px;left:1px;width:1px;height:0;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0"/><div class="flex flex-row"><div class="flex w-1/3 flex-col gap-2" role="tablist" aria-orientation="vertical"><button class="flex flex-col rounded-md border border-transparent p-4 text-left focus:outline-none ui-selected:border-dGrey1 dark:ui-selected:bg-dGrey1" id="headlessui-tabs-tab-:R5kmafkja:" role="tab" type="button" aria-selected="true" tabindex="0" data-headlessui-state="selected"><span class="__className_587f35 text-xs md:text-base opacity-80">Browse dream talent</span><span class="__className_587f35 text-3xs md:text-xs opacity-50">Find talent across 30+ top technologies</span></button><button class="flex flex-col rounded-md border border-transparent p-4 text-left focus:outline-none ui-selected:border-dGrey1 dark:ui-selected:bg-dGrey1" id="headlessui-tabs-tab-:R9kmafkja:" role="tab" type="button" aria-selected="false" tabindex="-1" data-headlessui-state=""><span class="__className_587f35 text-xs md:text-base opacity-80">Case Studies</span><span class="__className_587f35 text-3xs md:text-xs opacity-50">Testimonials & case studies on how we help clients</span></button><button class="flex flex-col rounded-md border border-transparent p-4 text-left focus:outline-none ui-selected:border-dGrey1 dark:ui-selected:bg-dGrey1" id="headlessui-tabs-tab-:Rdkmafkja:" role="tab" type="button" aria-selected="false" tabindex="-1" data-headlessui-state=""><span class="__className_587f35 text-xs md:text-base opacity-80">Why Flexiple?</span><span class="__className_587f35 text-3xs md:text-xs opacity-50">Learn about Flexiple & find helpful hiring guides</span></button></div><div class="w-2/3 pl-10"><div class="animate-fade-in" id="headlessui-tabs-panel-:R6kmafkja:" role="tabpanel" tabindex="0" data-headlessui-state="selected"><div class="px-5 pb-5"><div class="flex flex-row flex-wrap gap-2.5 md:gap-5 mb-5 md:mb-10"><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/dot-net">.NET</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/api-developers">API</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/asp-dot-net">ASP .NET</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/android">Android</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/angular">Angular</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/app">App</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/azure">Azure</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/backend">Backend</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/django">Django</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/express-js">ExpressJS</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/frontend">Frontend</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/fullstack">Fullstack</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/go">Golang</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/java">Java</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/javascript">JavaScript</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/laravel">Laravel</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/mobile">Mobile</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/node">NodeJS</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/php">PHP</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/programmers">Programmers</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/python">Python</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/react-native">React Native</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/react">ReactJS</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/ruby-on-rails">Ruby on Rails</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/software">Software</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/spring">Spring</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/swift">Swift</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/vue">VueJS</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/web">Web</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/ios">iOS</a></div><a class="group md:p-0" href="/developers"><span class="flex items-center gap-2"><span class="text-sm opacity-85 group-hover:underline group-hover:opacity-100 lg:text-base">Explore Our Dream Talent</span></span><span class="text-xs opacity-50 group-hover:opacity-85">Our top handpicked developers, engineers, architects and designers.</span></a></div></div><span aria-hidden="true" id="headlessui-tabs-panel-:Rakmafkja:" role="tabpanel" tabindex="-1" style="position:fixed;top:1px;left:1px;width:1px;height:0;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0"/><span aria-hidden="true" id="headlessui-tabs-panel-:Rekmafkja:" role="tabpanel" tabindex="-1" style="position:fixed;top:1px;left:1px;width:1px;height:0;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0"/></div></div></div></div></div><div class="group/dropdown flex h-full items-center rounded-sm border-b-2 border-white border-opacity-0 transition duration-300 hover:border-opacity-100"><button class="flex cursor-pointer items-center gap-2.5"><span class="__className_587f35 text-xs md:text-base opacity-80">For Talent</span><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-chevron-down transition-transform duration-300 group-hover/dropdown:rotate-180"><path d="m6 9 6 6 6-6"/></svg></button><div class="nav-dropdown absolute left-0 right-0 top-16 z-30 hidden bg-white px-20 py-12 shadow-md group-hover/dropdown:block group-focus/dropdown:block dark:bg-[#222222]"><div class="container mx-auto max-w-7xl"><button type="button" aria-hidden="true" style="position:fixed;top:1px;left:1px;width:1px;height:0;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0"/><div class="flex flex-row"><div class="flex w-1/3 flex-col gap-2" role="tablist" aria-orientation="vertical"><button class="flex flex-col rounded-md border border-transparent p-4 text-left focus:outline-none ui-selected:border-dGrey1 dark:ui-selected:bg-dGrey1" id="headlessui-tabs-tab-:R5l6afkja:" role="tab" type="button" aria-selected="true" tabindex="0" data-headlessui-state="selected"><span class="__className_587f35 text-xs md:text-base opacity-80">Browse jobs by skill</span><span class="__className_587f35 text-3xs md:text-xs opacity-50">Find jobs across 30+ top technologies</span></button><button class="flex flex-col rounded-md border border-transparent p-4 text-left focus:outline-none ui-selected:border-dGrey1 dark:ui-selected:bg-dGrey1" id="headlessui-tabs-tab-:R9l6afkja:" role="tab" type="button" aria-selected="false" tabindex="-1" data-headlessui-state=""><span class="__className_587f35 text-xs md:text-base opacity-80">Why Flexiple</span><span class="__className_587f35 text-3xs md:text-xs opacity-50">Learn why talent across the world love us</span></button><button class="flex flex-col rounded-md border border-transparent p-4 text-left focus:outline-none ui-selected:border-dGrey1 dark:ui-selected:bg-dGrey1" id="headlessui-tabs-tab-:Rdl6afkja:" role="tab" type="button" aria-selected="false" tabindex="-1" data-headlessui-state=""><span class="__className_587f35 text-xs md:text-base opacity-80">Resources</span><span class="__className_587f35 text-3xs md:text-xs opacity-50">Handcrafted guides to help grow your career</span></button></div><div class="w-2/3 pl-10"><div class="animate-fade-in" id="headlessui-tabs-panel-:R6l6afkja:" role="tabpanel" tabindex="0" data-headlessui-state="selected"><div class="px-5 pb-5"><div class="flex flex-row flex-wrap gap-2.5 md:gap-5 mb-5 md:mb-10"><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-javascript-developer-jobs">JavaScript</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-react-developer-jobs">ReactJS</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-angular-developer-jobs">Angular</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-node-js-developer-jobs">NodeJS</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-ios-developer-jobs">iOS</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-android-developer-jobs">Android</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-java-developer-jobs">Java</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-python-developer-jobs">Python</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-dotnet-developer-jobs">.NET</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-php-developer-jobs">PHP</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-flutter-developer-jobs">Flutter</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-ruby-on-rails-developer-jobs">Ruby on Rails</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-aws-developer-jobs">AWS</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-blockchain-developer-jobs">Blockchain</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-lamp-developer-jobs">LAMP</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-kotlin-developer-jobs">Kotlin</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-graphql-developer-jobs">GraphQL</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-django-developer-jobs">Django</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-vue-js-developer-jobs">Vue.js</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-docker-developer-jobs">Docker</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-laravel-developer-jobs">Laravel</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-css-developer-jobs">CSS</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-asp-dot-net-developer-jobs">ASP.NET</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-azure-developer-jobs">Azure</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-c-sharp-developer-jobs">C#</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-algorithms-developer-jobs">Algorithms</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-swift-developer-jobs">Swift</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-mongodb-developer-jobs">MongoDB</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-elasticsearch-developer-jobs">Elasticsearch</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-c-plus-plus-developer-jobs">C++</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-ionic-developer-jobs">Ionic</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-google-cloud-developer-jobs">Google Cloud</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-xamarin-developer-jobs">Xamarin</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-ruby-developer-jobs">Ruby</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-nosql-developer-jobs">NoSQL</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-go-developer-jobs">Go</a><a class="px-2.5 py-[5px] rounded-full border border-dGrey1/60 dark:border-white/60 bg-dGrey1/10 dark:bg-white/10 text-sm dark:text-white whitespace-nowrap hover:border-purple hover:bg-purple/50" href="/jobs/remote-react-native-developer-jobs">React Native</a></div><a class="group md:p-0" href="/jobs"><span class="flex items-center gap-2"><span class="text-sm opacity-85 group-hover:underline group-hover:opacity-100 lg:text-base">Explore Jobs</span></span><span class="text-xs opacity-50 group-hover:opacity-85">Handpicked jobs from top tech startups and companies.</span></a></div></div><span aria-hidden="true" id="headlessui-tabs-panel-:Ral6afkja:" role="tabpanel" tabindex="-1" style="position:fixed;top:1px;left:1px;width:1px;height:0;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0"/><span aria-hidden="true" id="headlessui-tabs-panel-:Rel6afkja:" role="tabpanel" tabindex="-1" style="position:fixed;top:1px;left:1px;width:1px;height:0;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0"/></div></div></div></div></div><div class="group/dropdown flex h-full items-center rounded-sm border-b-2 border-white border-opacity-0 transition duration-300 hover:border-opacity-100"><button class="flex cursor-pointer items-center gap-2.5"><span class="__className_587f35 text-xs md:text-base opacity-80">Our Products</span><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-chevron-down transition-transform duration-300 group-hover/dropdown:rotate-180"><path d="m6 9 6 6 6-6"/></svg></button><div class="nav-dropdown absolute left-0 right-0 top-16 z-30 hidden bg-white px-20 py-12 shadow-md group-hover/dropdown:block group-focus/dropdown:block dark:bg-[#222222]"><div class="container mx-auto max-w-7xl"><ul class="grid grid-cols-2 gap-2.5"><li class="rounded-[10px] border border-transparent bg-dGrey1/20 p-5 hover:border-dGrey1 dark:bg-dGrey1 dark:hover:bg-dGrey2"><a class="flex flex-col gap-2.5" href="/contractor"><div><span class="__className_587f35 text-base md:text-xl opacity-100">Hire Contractors</span><p class="__className_587f35 text-3xs md:text-xs opacity-50">Hire in 72 hours.</p></div><p class="__className_587f35 text-xs md:text-base opacity-80">Receive handpicked recommendations of contractors from a pre-vetted talent pool</p></a></li><li class="rounded-[10px] border border-transparent bg-dGrey1/20 p-5 hover:border-dGrey1 dark:bg-dGrey1 dark:hover:bg-dGrey2"><a class="flex flex-col gap-2.5" href="/full-time"><div><span class="__className_587f35 text-base md:text-xl opacity-100">Hire Full-time</span><p class="__className_587f35 text-3xs md:text-xs opacity-50">Hire in 2 weeks.</p></div><p class="__className_587f35 text-xs md:text-base opacity-80">Put your full-time hiring on auto-pilot as we source, evaluate and shortlist engineers for your roles</p></a></li></ul></div></div></div></div><div class="flex items-center justify-between gap-5"><button class="__className_4e0d06 font-medium flex justify-center items-center whitespace-nowrap rounded-[10px] focus:outline focus:outline-offset-2 py-1.5 px-5 border dark:border-white/40 border-dGrey1/40 dark:hover:bg-white/10 hover:bg-dGrey1/10 dark:hover:border-white hover:border-dGrey1 dark:disabled:bg-white/10 disabled:bg-dGrey1/10 dark:focus:outline-white focus:outline-dGrey1 dark:text-white text-dGrey1 cursor-pointer text-base md:text-lg gap-[5px]"><span class="__className_587f35 text-xs md:text-base opacity-80">Find Jobs</span><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-right "><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg></button><button class="__className_4e0d06 font-medium flex justify-center items-center gap-2 whitespace-nowrap focus:outline focus:outline-offset-2 hover:bg-purpleDark disabled:bg-purpleDark focus:outline-purpleDark !text-white cursor-pointer text-base md:text-lg text-pp rounded-[10px] bg-primary px-5 py-1.5"><span class="__className_587f35 text-xs md:text-base opacity-100">Hire Developers</span><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-right "><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg></button><button class="__className_4e0d06 font-medium flex justify-center items-center gap-2 whitespace-nowrap rounded-[10px] focus:outline focus:outline-offset-2 shadow-none px-0 py-0 outline-none hover:opacity-80 cursor-pointer text-base md:text-lg h-full"><span class="__className_587f35 text-xs md:text-base opacity-80">Login</span></button></div></nav></div></header><header class="fixed top-0 z-40 flex h-16 w-full items-center justify-between bg-white px-5 shadow lg:hidden dark:bg-dGrey1"><div class="flex gap-5"><button class="menu-button invert dark:invert-0" aria-label="toggle button"><div class="relative flex h-6 w-6 items-center justify-center"><span class="absolute h-px w-full bg-white transition-transform -translate-y-2"/><span class="absolute h-px w-full bg-white transition-transform opacity-100"/><span class="absolute h-px w-full bg-white transition-transform translate-y-2"/></div></button><a aria-label="Flexiple Homepage" class="flex" href="/"><img role="img" alt="Flexiple Logo" title="Flexiple Logo - Click to visit homepage" aria-label="Flexiple Homepage" loading="lazy" width="65" height="21" decoding="async" data-nimg="1" class="dark:invert" style="color:transparent" src="/_next/static/media/logo.59102633.svg"/></a></div><div class="flex items-center gap-4"><button class="__className_4e0d06 font-medium flex justify-center items-center gap-2 whitespace-nowrap rounded-[10px] focus:outline focus:outline-offset-2 shadow-none px-0 py-0 outline-none hover:opacity-80 cursor-pointer text-base md:text-lg h-full"><span class="__className_587f35 text-xs md:text-base opacity-80">Login</span></button><button class="__className_4e0d06 font-medium flex justify-center items-center gap-2 whitespace-nowrap focus:outline focus:outline-offset-2 hover:bg-purpleDark disabled:bg-purpleDark focus:outline-purpleDark !text-white cursor-pointer text-base md:text-lg text-pp rounded-[10px] bg-primary px-5 py-1.5"><span class="__className_587f35 text-xs md:text-base opacity-100">Hire Developers</span><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-right "><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg></button></div></header><nav class="fixed top-16 z-30 flex h-[calc(100%-4rem)] w-full flex-col gap-x-[30px] bg-white p-5 transition-all dark:bg-dGrey2 -left-full"><div class="flex-[1] overflow-y-auto"><button class="flex w-full items-center justify-between py-5" id="headlessui-disclosure-button-:R15qfkja:" type="button" aria-expanded="false" data-headlessui-state=""><span class="__className_587f35 text-base md:text-xl opacity-80">For Companies</span><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-chevron-down "><path d="m6 9 6 6 6-6"/></svg></button><div aria-hidden="true" class="mx-auto h-[1px] w-full bg-dGrey1/20 dark:bg-white/20"/><button class="flex w-full items-center justify-between py-5" id="headlessui-disclosure-button-:R1dqfkja:" type="button" aria-expanded="false" data-headlessui-state=""><span class="__className_587f35 text-base md:text-xl opacity-80">For Talent</span><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-chevron-down "><path d="m6 9 6 6 6-6"/></svg></button><div aria-hidden="true" class="mx-auto h-[1px] w-full bg-dGrey1/20 dark:bg-white/20"/><button class="flex w-full items-center justify-between py-5" id="headlessui-disclosure-button-:R1lqfkja:" type="button" aria-expanded="false" data-headlessui-state=""><span class="__className_587f35 text-base md:text-xl opacity-80">Our Products</span><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-chevron-down "><path d="m6 9 6 6 6-6"/></svg></button><div aria-hidden="true" class="mx-auto h-[1px] w-full bg-dGrey1/20 dark:bg-white/20"/><button class="__className_4e0d06 font-medium flex items-center gap-2 whitespace-nowrap rounded-[10px] focus:outline focus:outline-offset-2 shadow-none px-0 outline-none hover:opacity-80 cursor-pointer text-base md:text-lg justify-start py-5"><span class="__className_587f35 text-base md:text-xl opacity-80">Login</span></button></div><div class="grid grid-cols-2 items-end gap-5 border-t border-white border-opacity-20 pt-5"><button class="__className_4e0d06 font-medium flex justify-center items-center gap-2 whitespace-nowrap rounded-[10px] focus:outline focus:outline-offset-2 py-1.5 px-5 border dark:border-white/40 border-dGrey1/40 dark:hover:bg-white/10 hover:bg-dGrey1/10 dark:hover:border-white hover:border-dGrey1 dark:disabled:bg-white/10 disabled:bg-dGrey1/10 dark:focus:outline-white focus:outline-dGrey1 dark:text-white text-dGrey1 cursor-pointer text-base md:text-lg"><span>Find Jobs</span><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-right "><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg></button><button class="__className_4e0d06 font-medium flex justify-center items-center gap-2 whitespace-nowrap rounded-[10px] focus:outline focus:outline-offset-2 py-1.5 px-5 bg-purple hover:bg-purpleDark disabled:bg-purpleDark focus:outline-purpleDark !text-white cursor-pointer text-base md:text-lg"><span>Hire Developers</span><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-right "><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg></button></div></nav><main class="overflow-x-clip max-md:pt-10"><usefreefonts/><div class="fixed top-0 z-50 w-full bg-[#eee] py-5 !font-writer shadow transition-transform duration-300 max-md:hidden -translate-y-full"><div class="absolute left-0 bottom-0 h-1 bg-purple" style="width:0%"/><div class="mx-auto flex max-w-7xl items-center justify-between gap-16 px-4"><div class="relative"><button class="flex items-center gap-4"><p class="__className_587f35 text-xs md:text-base opacity-80 whitespace-nowrap !font-writer">Currently Reading :</p><div class="flex items-center gap-4"><span class="__className_587f35 text-xs md:text-base opacity-80 line-clamp-1 overflow-ellipsis text-left !font-writer font-bold text-purple">Table of Contents - Python String to Byte:</span><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-chevron-down shrink-0 transition-transform duration-300"><path d="m6 9 6 6 6-6"/></svg></div></button></div><div class="flex items-center gap-5"><button class="__className_4e0d06 font-medium flex justify-center items-center whitespace-nowrap rounded-[10px] focus:outline focus:outline-offset-2 py-1.5 px-5 border dark:border-white/40 border-dGrey1/40 dark:hover:bg-white/10 hover:bg-dGrey1/10 dark:hover:border-white hover:border-dGrey1 dark:disabled:bg-white/10 disabled:bg-dGrey1/10 dark:focus:outline-white focus:outline-dGrey1 dark:text-white text-dGrey1 cursor-pointer text-base md:text-lg gap-[5px]"><span class="__className_587f35 text-xs md:text-base opacity-80">Find Jobs</span><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-right "><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg></button><button class="__className_4e0d06 font-medium flex justify-center items-center gap-2 whitespace-nowrap focus:outline focus:outline-offset-2 hover:bg-purpleDark disabled:bg-purpleDark focus:outline-purpleDark !text-white cursor-pointer text-base md:text-lg text-pp rounded-[10px] bg-primary px-5 py-1.5"><span class="__className_587f35 text-xs md:text-base opacity-100">Hire Developers</span><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-right "><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg></button></div></div></div><button class="fixed bottom-0 left-0 right-0 z-50 flex flex-col border border-[#bbb] bg-white p-3 md:hidden"><div class="absolute left-0 top-0 h-1 bg-purple" style="width:0%"/><p class="__className_4e0d06 h6 font-medium tracking-[-0.15px] !font-normal">Currently reading:</p><div class="flex w-full items-center justify-between gap-2"><p class="__className_4e0d06 h5 tracking-[-0.15px] line-clamp-1 overflow-ellipsis text-left font-bold text-purple">Table of Contents - Python String to Byte:</p><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-chevron-up shrink-0 transition-transform duration-300"><path d="m18 15-6-6-6 6"/></svg></div></button><div class="fixed bottom-0 left-0 right-0 z-40 max-h-[70vh] w-full overflow-y-auto rounded-3xl border border-black/30 bg-white px-7 pb-20 pt-4 shadow-2xl transition-transform duration-300 md:hidden translate-y-full"><button aria-label="Hide Dropdown" class="mx-auto mb-4 block h-[3px] w-20 bg-dGrey3/90"/><div class="!font-writer"><a class="text-purple block py-1.5 hover:text-purple/80" href="#table-of-contents---python-string-to-byte:">Table of Contents - Python String to Byte:</a><a class="text-dGrey2 opacity-85 block py-1.5 hover:text-purple/80" href="#python-string-to-bytes:">Python String to Bytes:</a><a class="text-dGrey2 opacity-85 block py-1.5 hover:text-purple/80" href="#method-to-convert-strings-to-bytes:">Method to convert strings to bytes:</a><a class="text-dGrey2 opacity-85 block py-1.5 hover:text-purple/80" href="#limitations-and-caveats---python-string-to-byte">Limitations and Caveats - Python String to Byte</a></div></div><section class="container relative mx-auto max-w-7xl overflow-visible px-4 py-16 md:py-16"><div><ol class="flex flex-wrap items-center gap-1" aria-label="Breadcrumb"><li class="flex flex-row items-center gap-1"><a class="text-2xs text-blue/80 no-underline hover:underline md:text-sm" href="/">Home</a><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-chevron-right "><path d="m9 18 6-6-6-6"/></svg></li><li class="flex flex-row items-center gap-1"><a class="text-2xs text-blue/80 no-underline hover:underline md:text-sm" href="/blog">Blogs</a><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-chevron-right "><path d="m9 18 6-6-6-6"/></svg></li><li class="flex flex-row items-center gap-1"><a class="text-2xs text-blue/80 no-underline hover:underline md:text-sm" href="/python/blog">Python</a><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-chevron-right "><path d="m9 18 6-6-6-6"/></svg></li><li class="flex flex-row items-center gap-1"><span class="__className_587f35 text-2xs md:text-sm opacity-65">How to convert Python string to bytes?</span></li></ol><div class="flex items-start justify-between gap-10 mt-6"><h1 class="__className_4e0d06 h1 font-medium h2 -tracking-[1px]">How to convert Python string to bytes?</h1><div class="relative flex w-[400px] shrink-0 items-center gap-2.5 rounded-[10px] bg-dGrey1/5 py-5 pl-2.5 before:absolute before:-left-4 before:top-0 before:h-full before:w-[1px] before:bg-dGrey1/20 before:content-[''] max-lg:hidden"><div class="flex items-center gap-5"><img alt="Author image" loading="lazy" width="80" height="80" decoding="async" data-nimg="1" class="size-20 rounded-full object-cover object-center" style="color:transparent" src="/_next/static/media/AuthorAvatar.74c769b4.svg"/><div class="flex flex-col gap-3"><div><p class="__className_4e0d06 h5 font-bold -tracking-[1px]">Ancil Eric D'Silva</p><p class="__className_587f35 text-2xs md:text-sm opacity-80 !font-bold leading-[20px]">Software Developer</p></div><p class="__className_587f35 text-xs md:text-base opacity-80">Published on <!-- -->Thu Mar 10 2022</p></div></div></div></div><img alt="How to convert Python string to bytes? | Flexiple Tutorials | Python" aria-hidden="true" loading="lazy" width="1280" height="429" decoding="async" data-nimg="1" class="pt-5 lg:pt-10" style="color:transparent" src="/_next/static/media/Banner6.09b440c7.svg"/><div class="flex gap-20 pt-8 lg:pt-16"><div><div class="blog-content"><p>In this tutorial, we look at how to convert Python string to bytes. We look at all the various methods along with their limitations and caveats.</p> <h2 id="python-string-to-bytes:">Python String to Bytes:</h2> <p>Converting Python strings to Bytes has become quite popular after the release of Python 3. This is largely because a lot of file handling and Machine learning methods require you to convert them. Before we dive into how to convert them let us first understand what they are and how they are different.</p> <p>In Python 2, string and bytes were the same typeByte objects; however after the introduction of Python 3 Byte objects are considered as a sequence of bytes, and strings are considered as a sequence of characters. In essence, strings are human-readable and in order for them to become machine-readable, they must be converted to byte objects. This conversion also enables the data to be directly stored on the disk.</p> <p>The process of converting string objects to byte objects is called encoding and the inverse is called decoding. We look at methods to achieve this below.</p> <h2 id="method-to-convert-strings-to-bytes:">Method to convert strings to bytes:</h2> <p>There are many methods that can be used to convert Python string to bytes, however, we look at the most common and simple methods that can be used.</p> <h3 id="using-bytes():">Using bytes():</h3> <p>The bytes() method is an inbuilt function that can be used to convert objects to byte objects.</p> <p><strong>Syntax of bytes():</strong></p> <pre><code><span class="hljs-function"><span class="hljs-title">bytes</span><span class="hljs-params">(str, enc, error)</span></span> <p>The bytes take in an object (a string in our case), the required encoding method, and convert it into a byte object. The bytes() method accepts a third argument on how to handle errors.</p> <p>Let us look at the code to convert a Python string to bytes. The encoding type we use here is <a href="https://docs.python.org/3/howto/unicode.html" target="_blank" rel="noopener"> “UTF-8”</a>.</p> <pre><code>#<span class="hljs-keyword">Using</span> the byte() <span class="hljs-keyword">method</span> # <span class="hljs-title function_">initializing</span> <span class="hljs-title function_">string</span> <span class="hljs-title function_">str_1</span> = "<span class="hljs-title function_">Join</span> <span class="hljs-title function_">our</span> <span class="hljs-title function_">freelance</span> <span class="hljs-title function_">network</span>" <span class="hljs-title function_">str_1_encoded</span> = <span class="hljs-title function_">bytes</span><span class="hljs-params">(str_1,<span class="hljs-string">'UTF-8'</span>)</span> #<span class="hljs-title function_">printing</span> <span class="hljs-title function_">the</span> <span class="hljs-title function_">encode</span> <span class="hljs-title function_">string</span> <span class="hljs-title function_">print</span><span class="hljs-params">(str_1_encoded)</span> #<span class="hljs-title function_">printing</span> <span class="hljs-title function_">individual</span> <span class="hljs-title function_">bytes</span> <span class="hljs-title function_">for</span> <span class="hljs-title function_">bytes</span> <span class="hljs-title function_">in</span> <span class="hljs-title function_">str_1_encoded</span>: print(bytes, <span class="hljs-keyword">end</span> = <span class="hljs-string">' '</span>) <p>The output is as follows:</p> <pre><code><span class="hljs-attribute">b</span>'Join our freelance network' <span class="hljs-attribute">74</span> <span class="hljs-number">111</span> <span class="hljs-number">105</span> <span class="hljs-number">110</span> <span class="hljs-number">32</span> <span class="hljs-number">111</span> <span class="hljs-number">117</span> <span class="hljs-number">114</span> <span class="hljs-number">32</span> <span class="hljs-number">102</span> <span class="hljs-number">114</span> <span class="hljs-number">101</span> <span class="hljs-number">101</span> <span class="hljs-number">108</span> <span class="hljs-number">97</span> <span class="hljs-number">110</span> <span class="hljs-number">99</span> <span class="hljs-number">101</span> <span class="hljs-number">32</span> <span class="hljs-number">110</span> <span class="hljs-number">101</span> <span class="hljs-number">116</span> <span class="hljs-number">119</span> <span class="hljs-number">111</span> <span class="hljs-number">114</span> <span class="hljs-number">107</span></code></pre> <p>As you can see this method has converted the string into a sequence of bytes.</p> <p><strong>Note:</strong> This method converts objects into immutable bytes, if you are looking for a mutable method you can use the bytearray() method.</p> <h3 id="using-encode():">Using encode():</h3> <p>The <code><span class="hljs-function"><span class="hljs-title">encode</span><span class="hljs-params">()</span></span></code> method is the most commonly used and recommended method to convert Python strings to bytes. A major reason is that it is more readable.</p> <p><strong>Syntax of encode():</strong></p> <pre><code>string.encode(<span class="hljs-attribute">encoding</span>=encoding, <span class="hljs-attribute">errors</span>=errors) <p>Here, string refers to the string you are looking to convert.</p> <p><strong>Parameters:</strong></p> <li><strong>Encoding</strong> - Optional. The encoding method you are looking to use. After Python 3, UTF-8 has become the default.</li> <li><strong>Error</strong> - Optional, A string containing the error message.</li> <p><strong>Code to convert a python string to bytes:</strong></p> <pre><code>#<span class="hljs-keyword">Using</span> the encode <span class="hljs-keyword">method</span> # <span class="hljs-title function_">initializing</span> <span class="hljs-title function_">string</span> <span class="hljs-title function_">str_1</span> = "<span class="hljs-title function_">Join</span> <span class="hljs-title function_">our</span> <span class="hljs-title function_">freelance</span> <span class="hljs-title function_">network</span>" <span class="hljs-title function_">str_1_encoded</span> = <span class="hljs-title function_">str_1</span>.<span class="hljs-title function_">encode</span><span class="hljs-params">(encoding = <span class="hljs-string">'UTF-8'</span>)</span> #<span class="hljs-title function_">printing</span> <span class="hljs-title function_">the</span> <span class="hljs-title function_">encode</span> <span class="hljs-title function_">string</span> <span class="hljs-title function_">print</span><span class="hljs-params">(str_1_encoded)</span> #<span class="hljs-title function_">printing</span> <span class="hljs-title function_">individual</span> <span class="hljs-title function_">bytes</span> <span class="hljs-title function_">for</span> <span class="hljs-title function_">bytes</span> <span class="hljs-title function_">in</span> <span class="hljs-title function_">str_1_encoded</span>: print(bytes, <span class="hljs-keyword">end</span> = <span class="hljs-string">' '</span>) <p>The output is the same as above.</p> <pre><code><span class="hljs-attribute">b</span>'Join our freelance network' <span class="hljs-attribute">74</span> <span class="hljs-number">111</span> <span class="hljs-number">105</span> <span class="hljs-number">110</span> <span class="hljs-number">32</span> <span class="hljs-number">111</span> <span class="hljs-number">117</span> <span class="hljs-number">114</span> <span class="hljs-number">32</span> <span class="hljs-number">102</span> <span class="hljs-number">114</span> <span class="hljs-number">101</span> <span class="hljs-number">101</span> <span class="hljs-number">108</span> <span class="hljs-number">97</span> <span class="hljs-number">110</span> <span class="hljs-number">99</span> <span class="hljs-number">101</span> <span class="hljs-number">32</span> <span class="hljs-number">110</span> <span class="hljs-number">101</span> <span class="hljs-number">116</span> <span class="hljs-number">119</span> <span class="hljs-number">111</span> <span class="hljs-number">114</span> <span class="hljs-number">107</span> <p>Similar to the encode() method, the decode() method can be used to convert bytes to strings.</p> <pre><code>#<span class="hljs-keyword">Using</span> the encode <span class="hljs-keyword">method</span> #<span class="hljs-title function_">initializing</span> <span class="hljs-title function_">string</span> <span class="hljs-title function_">str_1</span> = "<span class="hljs-title function_">Join</span> <span class="hljs-title function_">our</span> <span class="hljs-title function_">freelance</span> <span class="hljs-title function_">network</span>" <span class="hljs-title function_">str_1_encoded</span> = <span class="hljs-title function_">str_1</span>.<span class="hljs-title function_">encode</span><span class="hljs-params">(encoding = <span class="hljs-string">'UTF-8'</span>)</span> #<span class="hljs-title function_">printing</span> <span class="hljs-title function_">the</span> <span class="hljs-title function_">encode</span> <span class="hljs-title function_">string</span> <span class="hljs-title function_">print</span><span class="hljs-params">(str_1_encoded)</span> #<span class="hljs-title function_">decoding</span> <span class="hljs-title function_">the</span> <span class="hljs-title function_">string</span> <span class="hljs-title function_">str_1_decoded</span> = <span class="hljs-title function_">str_1_encoded</span>.<span class="hljs-title function_">decode</span><span class="hljs-params">()</span> <span class="hljs-title function_">print</span><span class="hljs-params">(str_1_decoded)</span> <p>Output</p> <pre><code>b<span class="hljs-string">'Join our freelance network'</span> <span class="hljs-keyword">Join</span> our freelance network</code></pre>
推荐文章
老实的打火机
·
沈阳地铁九号线东延线要开建了,北延线还有戏吗?
4 月前
很拉风的西红柿
·
《世界设计现代史》人物篇——现代设计之父威廉·莫里斯 - 哔哩哔哩
5 月前
酷酷的熊猫
·
appium uiautomator server 2的一个bug - appcrawler - 测试人社区
6 月前
大鼻子的煎鸡蛋
·
【第736篇】i社游中国官网app最新正版_哔哩哔哩_bilibili
6 月前
寂寞的杯子
·
64线混合固态激光雷达 CB64S1
10 月前