数字 写在最前,必须要会的:int() 整型 Python3里无论数字多长都用int表示,Python2里有int和Long表示,Long表示长整型 有关数字的常用方法,方法调用后面都必须带括号() int():将字符串转换为整型,且字符串内容只能是数字 a = " b = "123a" c = int(a) d = int(b) # ValueError: invalid literal for int() with base 10: '123a' print(type(c
Python 基础:字符串,数字,变量 1. 字符串 (信息的一种表达方式) a. 使用引号创建字符串 b. 单引号,双引号,三引号: ', ", ''', """ c. print函数: print('hello', end=',');print('world', end=';') d. 和字符串显示格式相关的应该想到print函数,print函数可以指定不同的结束字符串. e. ascii art """ ##### #######