简体   繁体   English

类型错误:“int”类型的参数不可迭代 - python 3.5

[英]TypeError: argument of type 'int' is not iterable - python 3.5

While doing data transformation, I am getting "TypeError: argument of type 'int' is not iterable", I am using python 3.5在进行数据转换时,我收到“TypeError:'int' 类型的参数不可迭代”,我使用的是 python 3.5

This is the code snippet,这是代码片段,

for idx, val in enumerate(aircrashdf.Destination):
if ',' in val:
    destination = val.split(",")
    original = destination[0].strip()
    aircrashdf.iloc[idx,10] = original

This is the output这是输出

    Traceback (most recent call last):
  File "/home/drogon/PycharmProjects/aircrashes.py", line 151, in <module>
    if ',' in val:
TypeError: argument of type 'int' is not iterable

What could be the problem?可能是什么问题呢?

for循环中, val值是一个类型的integer和你正在努力探索,在一个integer

it seems to me that type of val variable is int, you can check type of any function and variable by using type() function..it will return the type of variable....you can also compare the type of variable by using following code... '在我看来,val 变量的类型是 int,您可以使用 type() 函数检查任何函数和变量的类型..它会返回变量的类型..您也可以使用以下方法比较变量的类型以下代码...'

# if type is same as you provided then it will return true
if isinstance(var_name, data_type):
# your code here

' '

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM