小编use*_*042的帖子

在.txt中查找数字的平方

请,我想找到存储在名为'myNumbers.txt'的.txt文件中的数字的方块

myNumbers.txt

2
3
4
5
3
Run Code Online (Sandbox Code Playgroud)

我有这些python脚本:

if __name__=="__main__":
     f_in=open("myNumbers.txt", "r")     
     for line in f_in:                  
          line=line.rstrip()
          print float(line)**2

     f_in.close()
Run Code Online (Sandbox Code Playgroud)

我尝试了这个并且它工作得非常好,但我想知道是否还有其他方法.

python file gedit

1
推荐指数
1
解决办法
51
查看次数

标签 统计

file ×1

gedit ×1

python ×1