import;import...from...;import...as...的区别

import datetime

print(datetime.datetime.now())
import datetime from datetime
print(datetime.now())
import datetime as t
print(t.datetime.now())

datetime = datetime.datetime

以上代码实现输出系统当前时间,是引入整个datetime包,然后再调用datetime这个类中的now()方法,第三个是帮datetime定义了一个别名。

import c3 from (a, b, c,
d)

python规定可以导入多个参数(一行80个);

换行可以有两种:

1、利用\:a, b, c,\

d

2、利用():(a, b, c,

d)

猜你喜欢

转载自blog.csdn.net/x__torrey/article/details/82114242