Python中文
首页
教程
问答
标签
搜索
登录
注册
“如果”状态下的多项任务
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>为什么我不能在python中的if语句下进行多个赋值?有没有我遗漏的语法?在</p> <p>我想这样做:</p> <pre><code>files = ["file1", "file2", "file3"] print "\nThe following files are available: \n" i = 0 for file in files: i = i + 1 print i, file choice = int(raw_input("\Enter a file number: ")) if choice ==1: file = np.genfromtxt(files[0], usecols = (1,2,3), dtype = (float), delimiter = '\t') time = np.genfromtxt(files[0], usecols = (0), dtype = (str), delimiter = '\t') print time </code></pre> <p>时间是在if语句之外定义的,所以它不会随着选择的改变而改变……这到底是怎么回事?在</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>变量file和time必须在比if语句更高的块级别上定义。在</p> <p>注意“time”,因为它是python模块的名称。您应该使用此名称的变体(例如time)。在</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
将Pandas数据帧转换为PyTorch张量?
3 回答
将Pandas数据帧转换为scipy稀疏矩阵
6 回答
将Pandas数据帧转换为Spark Datafram时出现问题
1 回答
将pandas数据帧转换为spark DataFram时出错
9 回答
将Pandas数据帧转换为spark datafram时收到错误
10 回答
将Pandas数据帧转换为Spark数据帧
4 回答
将Pandas数据帧转换为Tensorflow数据
8 回答
将Pandas数据帧转换为tkinter obj
6 回答
将pandas数据帧转换为XML
5 回答
将Pandas数据帧转换为值sql语句
1 回答
将pandas数据帧转换为元组
5 回答
将pandas数据帧转换为元组列表
1 回答
将pandas数据帧转换为元组列表并删除所有pandas数据类型
6 回答
将pandas数据帧转换为具有头和数据类型的numpy数组
1 回答
将pandas数据帧转换为内存中的拼花地板,并将其加载到Python中的Hadoop中
10 回答
将pandas数据帧转换为内存中类似文件的对象?
8 回答
将Pandas数据帧转换为内存功能(&F)
2 回答
将pandas数据帧转换为列表列表
2 回答
将pandas数据帧转换为列表列表以输入到RNN
6 回答
将Pandas数据帧转换为单行DataFram
7 回答