小编sun*_*nny的帖子

动态处理python字符串或列表

numberofrow,其值在表单字段中动态设置.

现在,因为numberofrow在多个表中,当我从表单中收到该变量时,

如果只有一个numerofrow,它的一个字符串,例如.numberofrow = 01

如果不止一个numberofrow,它是一个列表,例如.numberofrow = [01,02,04]

现在我如何区分我的python代码中的列表或字符串?

我正在考虑使用,

if type(numberofrow).__name__=='list':
    #do this
else:
    #do this
Run Code Online (Sandbox Code Playgroud)

谢谢,Sunny.

python

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

标签 统计

python ×1