Python built-in function of STR ()

Source: Internet
Author: User

Class Str (object= "")
Class str (object=b ', encoding= ' utf-8 ', errors= ' strict ')

Converts another object to a string object.

Example:

>>> Str (123)'123'>>>str ()"'>>> file = open ('Data.txt','RB')>>> fb =File.read ()>>>Str (FB)"B ' \\xe5\\xa4\\xa9\\xe7\\x8e\\x8b\\xe7\\x9b\\x96\\xe5\\x9c\\xb0\\xe8\\x99\\x8e\\xef\\xbc\\x8c\\xe5\\xb0\\x8f\\xe9\\xb8\\xa1\\xe7\\x82\\x96\\xe8\\x98\\x91\\xe8\\x8f\\x87\\xe3\\x80\\x82'">>> Str (FB,'Utf-8') #指定编码集'King cover the ground tiger, chicken stew mushroom. '>>> Str (FB,'GBK','Ignore') #指定报错级别'澶 ╃ Hermetic Monitoring paragraph ban payload 庯 紝 Hao souvenirs float 鐐dfap No. è 囥'>>> File.close ()

Python built-in function of STR ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.