Conversions between Python data types

Source: Internet
Author: User
Tags goto

1, string-to-integer, provided the string is a pure number.

A = ' 1 ' a = Int (a)

  

2, integer-to-string

A= 1a = str (a)

  

3, integer-to-float

A = 1a = float (a)

  

4, floating-point type

A = 1.2a = Int (a)

  

5, String goto list

A = ' abc ' A = List (a)

  

6, List to string

list = [' A ', ' B ', ' C '] '. '. Join (List1)

 

7, String goto ancestor

A= ' abc ' a= tuple (a)

8, meta-ancestor turn string

Tuple1= (' A ', ' B ', ' C ') '. '. Join (TUPLE1)

  

9, Ganso and list to dictionary (the element in the precondition list must consist of a list of two elements or a tuple)

List1 = ([' Name ', ' Tom '), (' Age ', '] ') ') print dict (List1)

  

10, Dictionary converted to list

dict1={' name ': ' Tom ', ' age ': ' + '}list1 = Dict1.items ()

  

Conversions between Python data types

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.