- 博客(6)
- 收藏
- 关注
原创 2种方式利用索引
代码一:fourth = input('Year: ')[3] 输入:Year:1995结果 :>>>fourth>>>'5'代码二:fourth = input('Year: ') 输入:Year:1995结果:>>>fourth[2]>>>'9'注意代码一与代码二第一行的区别...
2020-09-16 12:03:47
168
原创 代码美观
year = input('Year: ')month = input('Month(1-12): ')day = input('Day(1-31): ')year = input('Year: ')month = input('Month(1-12): ')day = input('Day(1-31): ')代码美观可读性更强
2020-09-16 11:53:54
215
原创 字符串跨越多行
使用长字符 print('''This is a very long string.It continues here.And it's not over yet."Hello,world!"Still here.''') #'''可以换成""",即单引号换成双引号 使用反斜杠(\)print("Hello,\world!")#这种处理手法也适用于表达式和语句...
2020-09-09 22:13:53
188
原创 ‘ ‘与“ ”区别
' '与“ ”区别"Let's go!" 运行结果:Let’s go!‘Let's go!’ 运行结果:SyntaxError: invalid syntax原因:'Let's go!'此段代码中,有三个 ’,强调一下,有三个 ’,再python中前两个 ‘ 构成一个语句,故报错。...
2020-08-09 16:55:02
667
原创 python 函数名称
python函数名称pow( ,) //pow(2,3) ==> 2^3 = 8abs(A) //计算A的绝对值round(A/B) //最接近A/B的整数
2020-08-09 15:39:03
399
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅