Python基础之数据类型
- 运行程序,输入19.9, 结果是: score=input() result = float(score) print(int(result)) : 19
- 输入991,则程序的执行结果是: num1 = int(input()) num2=int(input()) print(“sum is %d”%(num1+num2)) : 100
- 当需要在字符串中使用特殊字符时,python使用 ()作为转义字符。
- Python中表示复数的语法形式是a+bj
- Python中复数虚部必须加后缀
- Python中函数abs()可以求复数的模
- Python支持的数据类型有int、float、list
- 标识符: _
- Python中表示复数的语法是real + image j
- Python中复数实部和虚部都是浮点数
- Python中方法conjugate返回复数的共轭复数
- Python变量不必事先声明
- python变量无须指定类型
- Python内存管理可以使用del释放资源
- 表达式’abcabcabc’.rindex(‘abc’)的值为: 6
- 表达式str((1,2, 3))的值为’(1, 2, 3)’
- 表达式str([1,2, 3])的值为’[1, 2, 3]’
- 已知path = r’c:\test.html’,那么表达式path[:-4]+‘htm’的值为: c: \test.htm’
- 表达式’ab’ in 'acbed’的值为False
- 表达式print(0b10101)的值为21
- 以3为实部4为虚部,Python复数的表达形式为3+4j 或 3+4J
- 查看变量内存地址的Python内置函数是id()
- 看变量类型的Python内置函数是type()
- 字符串属于Python有序序列,和列表、元组一样都支持双向索引。
- 将数字格式化为货币符号
import locale
def toMoney(str):
#start
money=float(str)
#end
money=input()
locale.setlocale(locale.LC_ ALL,'')
number=toMoney (money)
print(locale. format("%2. f' , number, 1))
精彩内容敬请期待!