Python 语法
- 打印 "Hello World"
https://www.w3school.com.cn/tiy/t.asp?f=python_default
- Python 中的注释
https://www.w3school.com.cn/tiy/t.asp?f=python_syntax_comment
- 文档字符串(Docstrings)
https://www.w3school.com.cn/tiy/t.asp?f=python_docstring
例子解释:语法https://www.w3school.com.cn/python/python_syntax.asp
print("Hello World!!! ")
#This is a comment.
print("Hello, World!")
"""This is a
multiline docstring."""
print("Hello, World!")
Python 变量
x = 10
y = "Bill"
print(x)
print(y)
x = "awesome"
print("Python is " + x)
x = "Python is "
y = "awesome"
z = x + y
print(z)
Python 数字
x = 10
y = 6.3
z = 2j
print(type(x))
print(type(y))
print(type(z))
x = 10
y = 37216654545182186317
z = -465167846
print(type(x))
print(type(y))
print(type(z))
x = 3.50
y = 2.0
z = -63.78
print(type(x))
print(type(y))
print(type(z))
x = 27e4
y = 15E2
z = -49.8e100
print(type(x))
print(type(y))
print(type(z))
x = 2+3j
y = 7j
z = -7j
print(type(x))
print(type(y))
print(type(z))
Python Casting
x = int(1)
y = int(2.5)
z = int("3")
print(x)
print(y)
print(z)
x = float(1)
y = float(2.5)
z = float("3")
w = float("4.6")
print(x)
print(y)
print(z)
print(w)
x = str("S2")
y = str(3)
z = str(4.0)
print(x)
print(y)
print(z)