Python:列表理解,如果x存在,请执行f(x)吗?

AP2*_*257 12 python list-comprehension

我怎样才能在Python中执行以下操作?

row = [unicode(x.strip()) if x for x in row]
Run Code Online (Sandbox Code Playgroud)

基本上,列表理解,如果变量存在,您执行函数.

谢谢!

Ada*_*erg 18

"if"结尾"

row = [unicode(x.strip()) for x in row if x]
Run Code Online (Sandbox Code Playgroud)