注释
# 为了代码的可读性,#后面要有一个空格
print("hello,world") # 在代码后面加注释,为了程序的可读性,代码与程序之间至少有两个空格
"""
多行注释,一对连续的三个引号(单引号,双引号都ok)
"""
print输出函数
'''
print默认自动换行
在后面加end属性就不会自动换行
'''
print("hello", end="--")
print("hello", end="@")
print("hello")
'''
hello,world
hello--hello@hello
'''
# 输入 input接受键盘输入,统一为字符串
name = input("你的名字:")
print(name)
'''
你的名字:vvv
vvv
'''
常用函数
# help查看帮助信息,会打印出print下的属性及其解释
help(print)
# dir查看对象的属性和方法
print(dir(print))
print("-------------")
a = 10
# id查看对象存储地址
print(id(a))
print("-------------")
# type查看对象类型
print(type(a))
# 删除
# del a
print(a) # 报错:a未被定义
# len 查看数据的长度
name = "Alice"
print(len(name))
导包方法
# 1直接导入os包
import os
print(os.getcwd())
# 2导入os包中的方法
from os import getcwd
print(getcwd())
# 3将getcwd重新定义一个名字
from os import getcwd as gt
print(gt())