在这篇文章中,我们将通过一个简单的python例子,来了解python的一些基础知识,并为我们接下来的学习打下基础
#定义了一个函数名是main的函数 “def 函数名(参数1,参数2,...):“
def main():
#python代码通过缩进来表示代码块
print("golang369.com")
#调用函数
main()
运行程序,结果如下图
and | or | not |
assert | finally | exec |
while | for | break |
continue | if | else |
elif | global | yield |
def | from | return |
del | import | lambda |
class | in | pass |
is | with | |
except | try | raise |
4.Python中的注释: 注释用于解释代码的作用,注释不会被解释器执行。Python中单行注释以 # 开头,多行注释可以用多个 # 号,还有一种便捷的方式是使用三引号( ''' 或者 """ )
'''这是单引号的
多行注释'''
"""这是双引号的
多行注释"""
print
5.print:如果需要输出内容到屏幕,可以使用print函数。
6.python字符串:在python中,字符串可以用单引号(’)或者双引号(”)表示。如果是多行字符串,那么可以使用三引号(’’’或者”””)
dan='单引号字符串'
shuang="双引号字符串"
sandan='''hello
hello'''
sanshuang="""hello
hello"""
页面更新:2024-05-09
本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828
© CopyRight 2020-2024 All Rights Reserved. Powered By 71396.com 闽ICP备11008920号-4
闽公网安备35020302034903号