专业编程基础技术教程

网站首页 > 基础教程 正文

python库的属性方法帮助以及ascII

ccvgpt 2024-11-15 16:51:21 基础教程 71 ℃

本文示例了python库的所有属性方法以及帮助信息,并介绍了ascII码字符和字符编号

代码如下:

python库的属性方法帮助以及ascII

import math

print(dir(math))   #打印math库的所有属性方法
print(help(math.modf)) #打印math库的modf有属性方法
print(math.modf(10))
print(math.__doc__)  #打印math的描述性说明
ch1="A"
print("ord(ch1)即A的字符编码:",ord(ch1))  #打印A的字符串的ASCII字符集编号,A的长度只能为1
ch2="a"
print("ord(ch2)即a的字符编码:",ord(ch2))
print("97的字符:",chr(97))     #打印97对应的ASCII字符
ch3="中"
print("ord(ch3):",ord(ch3))    #打印汉字中的ASCII字符集编号

代码运行结果如下:

['__doc__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'gcd', 'hypot', 'inf', 'isclose', 'isfinite', 'isinf', 'isnan', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'log2', 'modf', 'nan', 'pi', 'pow', 'radians', 'remainder', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'tau', 'trunc']

Help on built-in function modf in module math:

modf(x, /)

Return the fractional and integer parts of x.

Both results carry the sign of x and are floats.

None

(0.0, 10.0)

This module is always available. It provides access to the

mathematical functions defined by the C standard.

ord(ch1)即A的字符编码: 65

ord(ch2)即a的字符编码: 97

97的字符: a

ord(ch3): 20013


图片示例如下:


Tags:

最近发表
标签列表