- 博客(3)
- 收藏
- 关注
原创 Python中的DocStrings
DocStrings(文档字符串)是Python中的一个特性,它可被用于函数、模块和类。 它的作用是为程序添加注释,让程序更加的简单易懂(即增加程序可读性)。 例如可以在函数后书写DocStrings,用于解释函数的作用、参数的类型与意义、返回值类型与取值范围等。def printMax(x,y): '''Print the maximum of two numbers. The two
2016-10-16 22:53:25
1950
原创 Python中if/else结构的缩进
缩进在Python中非常重要。 # vim: set fileencoding=utf-8 : number=23 guess=int(raw_input('please input a number:')) if guess==number: print 'Congratulations!you guessed it' elif guess print 'the
2016-10-16 15:24:37
2235
原创 Python如何进行中文注释
最近课程大作业接触到了Python语言,编写了一个小程序后发现一个问题: Python默认是采用ASCII编码,当中文出现在Python代码中(即使是出现在注释中)就会产生SynsaxError。 解决办法是:在Python代码第一行加上 方法一: # coding=utf-8 方法二: # -*- coding: utf-8 -*- 方法三: # vim: set filee
2016-10-16 14:45:37
288
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人