Python - 内置函数 - o

# object()
# oct()
# open()
# ord()

# 内置函数:object()
# 创建一个新的对象
# 该函数是所有类的基类

new_object = object()
print(new_object)

# 内置函数:oct()
# 将一个整数转换为八进制字符串
# 返回字符串以"0o"开头,表示是八进制数字

number = 10
oct_string = oct(number)
print(oct_string)

# 内置函数:open()
# 打开一个文件,并返回一个文件对象
# 参数包括文件名和打开模式

file_name = "example.txt"
file_mode = "r"  # 只读模式
file_object = open(file_name, file_mode, encoding='utf-8')
print(file_object)

# 内置函数:ord()
# 返回一个字符的整数表示
# 只接受单个字符作为参数

character = 'A'
char_int = ord(character)
print(char_int)




猜你喜欢

转载自blog.csdn.net/qq_43116031/article/details/131011433