1. Start Basics 1.1 first Python code
First create an arbitrary file, ending py format, then enter the code inside, run pycharm or Python shell inside
print ( "fishing to catch saury, saury fishing to the island")
1.2 interpreter encoding
ascii, 8 bits = 1 byte, a byte is a letter, Py2 default interpretation is encoded in ASCII.
Unicode, 32 bits = 4 bytes, called Unicode, a letter or characters are four bytes
utf-8, which is a compressed version of unicode, a byte is a letter, a character is three bytes, Py3 default interpreter code is utf-8
1.3 Output
print ( "Enter what you want to enter.")
1.4 Variable
Name of the variable letters, numbers, underscores, and can not start with a number, not a built-in Python keywords as variable names. Named variables known to do see name meaning, connections underlined link
1.4.1 Assignment of variables
x=1+2+3+4+5 y=x*5 z=y*7 print(z) age1=18 age2=age1 age1=12 age3=age2 print(age1,age2,age3) age=12 age=12+1 age1=age+1 print("我今年:",age1) name1='alex' name2=name1 name1='wusir' name3=name2 print(name1,name2,name3) num1=2 num2=3 print(num1+num2)
1.5 Notes
General single-line comments in a line beginning with #, multi-line comments in the first row on the line and last line of the next line plus "" "If you want multiple single-line comments while pycharm inside, then use the keyboard shortcut Ctrl +?
1.6 General Data Types
str is a string
1.6.1 string splicing
s1="a" s2='bc' print(s1+s2)
1.6.2 string multiplication
name = "I love to learn Python" Print (name * 8) # I love learning Pythonch repeated eight times