晓响雷鸣 发表于 2018-6-30 13:54:17

找个乐子!python代码是从上往下阅读的很明显,但是怎么验证每行代码是从左往右读的?

尽量用最简单的方法{:10_289:}

liuzhengyuan 发表于 2018-6-30 14:15:08

本帖最后由 liuzhengyuan 于 2018-6-30 14:35 编辑

static/image/hrline/line7.pngstatic/image/hrline/line7.pngstatic/image/hrline/line7.pngstatic/image/hrline/line7.pngstatic/image/hrline/line7.pngstatic/image/hrline/line7.pngstatic/image/hrline/line7.pngstatic/image/hrline/line7.png

很简单,凭直觉{:5_91:}

static/image/hrline/line7.pngstatic/image/hrline/line7.pngstatic/image/hrline/line7.pngstatic/image/hrline/line7.pngstatic/image/hrline/line7.pngstatic/image/hrline/line7.pngstatic/image/hrline/line7.pngstatic/image/hrline/line7.png



晓响雷鸣 发表于 2018-6-30 19:10:03

没人玩吗??{:10_266:}

晓响雷鸣 发表于 2018-6-30 19:11:01

liuzhengyuan 发表于 2018-6-30 14:15
很简单,凭直觉

贵族专用字体颜色

指头比思想慢 发表于 2018-7-16 17:12:11

没有定义nn按理说要出错,但是实际没有出错,因为运行到 i==1就直接运行下一步了
i = 1
if i == 1 or nn == 1:
        print(1)

我不是皮卡@ 发表于 2018-7-16 18:24:14

Python中一般是一行写完所有代码,如果遇到一行写不完需要换行的情况,有两种方法:

1.在该行代码末尾加上续行符“ \”(即空格+\);

test = 'item_one' \

'item_two' \

'tem_three'

输出结果:'item_oneitem_twotem_three'

2.加上括号,() {}[]中不需要特别加换行符:

test2 = ('csdn '

'cssdn')

输出结果:csdn cssdn



if...and:

if (where there is a will and

there is a way)

多次未输出结果



test3 =('Hello'

' '

'world')

输出结果:Hello world

圣剑三刀。abx 发表于 2018-7-19 13:46:52

print(lst)==lst.reverse()
会先打印,再翻转,所以说是从左往右的。
页: [1]
查看完整版本: 找个乐子!python代码是从上往下阅读的很明显,但是怎么验证每行代码是从左往右读的?