Write some of Python's pits: Pocket API, type judgment, Unicode write file, raise

Source: Internet
Author: User

1.pocket API

The Pocket new API does not allow you to send a username and password directly, so you need to apply for the app's Consumer_key, then Get_request_token, get a request_token, and then Consumer_ Key and Request_token use a browser to access the authorize website, then manually click Authorize and then return to Access_token. In the future, the use of Consumer_key and Access_token in the application can be used to the operation of the account (add, delete).

It's very well implemented in Python.

2.python type judgment

Isinstance ([1,2,3,4], list)

3. Write Unicode to file

Import codecsf = codecs.open ('out.txt'a'  Utf-8')f.write (U' text ')f.close ()

4.raise

Try : if  ... ... .. Else : Raise # raise must be an object derived from exception () or error () except : ... .. Else : ... .. finally : ...        

BnkR. @ Www.cnblogs.com/bnkr

Write some of Python's pits: Pocket API, type judgment, Unicode write file, raise

Related Article

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.