I have this code that extracts only digits from a string:
infotype = (int(s) for s in chooseMappingStr.split() if s.isdigit())
If i print infotype it returns a generator object:
'<generator object dBQuery_foreignTable.<locals>.<genexpr> at 0x0000018A60CF33C0>'
Is there a way to return a int value from it?
Just put []
instead of ()
:
infotype = [int(s) for s in chooseMappingStr.split() if s.isdigit()]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.