Python Note 5-character, String type

Source: Internet
Author: User

Character, String type
#print (1/2)
# print (1//2) #地板除, is automatic rounding, not rounding, directly erase the decimal
#if判断时候, both true and false, that is, true and false.

Non-0 is true, non-null is True

Name=input ("Please enter your name:")
Name:
Print (name)
Else
Print ("error ....")

1 , Boolean type
Bool=false;
Printbool;
Bool=true;
Printbool;

2 , Integer
int=20;
print int;

3 , floating point
float=2.3;
print float;

4 , Digital
Include integers, floating-point numbers.
4.1. Delete numeric object references, for example:
A=1;
b=2;
c=3;
Del A;
del B, C;
#print A; #删除a变量后, calling the A variable again will cause an error.

2. character type conversions

Numeric type conversions

int (x [, Base]) converts x to an integer

Float (x) converts x to a floating-point number

Complex (real [, Imag]) creates a complex number

STR (x) converts an object x to a string

REPR (x) converts an object x to an expression string

Eval (str) is used to calculate a valid Python expression in a string and returns an object

Tuple (s) converts a sequence s to a tuple

List (s) converts the sequence s to a list

Chr (x) converts an integer to one character

UNICHR (x) converts an integer to a Unicode character

Ord (x) converts a character to its integer value

Hex (x) converts an integer to a hexadecimal string

Oct (x) converts an integer to an octal string

Python Note 5-character, String type

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.