如何在Python中使用括号? [英] How to use brackets in Python?

查看:415
本文介绍了如何在Python中使用括号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

展开 | 选择 | Wrap | 行号

推荐答案

括号是用作列表分隔符,序列类型索引和切片运算符的标记。我不认为你的方法会达到你想要的效果。 file 方法read()将整个文件作为一个字符串读取。您可以迭代文件对象(对于fileObj :)中的行,并对其他两个文件使用文件方法 next(),这样您就可以对每个文件的第1行执行任何操作,然后行每个文件中有2个,依此类推。
Brackets are tokens used as delimiters for lists, index of sequence types, and the slicing operator. I don''t think your method will achieve the results you want. file method read() reads the entire file as one string. You could iterate on the file object (for line in fileObj:) and use file method next() on the other two files, so you could do whatever you need to line 1 of each file, then line 2 of each file, and so on.


我不知道你说的一半?请用更简单的方式解释
i don''t know half of what you saying? please explain in a more simpler


一个列表:
展开 | 选择 | Wrap | 行号


这篇关于如何在Python中使用括号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆