美文网首页
python3 (一)基础知识

python3 (一)基础知识

作者: 一只苍白的黑 | 来源:发表于2018-06-28 10:42 被阅读0次

1、python中的注解:

单行注解 #

多行注解 '''   .....  ''' 或 """ ...... """

2、python多行语句:

Python 通常是一行写完一条语句,但如果语句很长,我们可以使用反斜杠(\)来实现多行语句

total = item_one + \

        item_two + \

        item_three

在 [], {}, 或 () 中的多行语句,不需要使用反斜杠(\),例如:

total = ['item_one', 'item_two', 'item_three', 

         'item_four', 'item_five']

print输出:print 默认输出是换行的,如果要实现不换行需要在变量末尾加上 end="":  print( x, end=" " )

3、导入模块

将整个模块(somemodule)导入,格式为: import somemodule

从某个模块中导入某个函数,格式为: from somemodule  import   somefunction

从某个模块中导入多个函数,格式为: from somemodule  import  firstfunc, secondfunc

将某个模块中的全部函数导入,格式为: from somemodule import *

相关文章

网友评论

      本文标题:python3 (一)基础知识

      本文链接:https://www.haomeiwen.com/subject/bffgyftx.html