JZTXT
  • 首页
  • Ai
  • Java
  • Python
  • Android
  • Mysql
  • JavaScript
  • Html
  • CSS

convert string list to number list

发布时间 2023-07-03 10:29:49作者: xiaoxuxli
#string with integers sepated by spaces
string1="1 2 3 4 5 6 7 8"
print("Actual String containing integers: ",string1)
print("Type of string: ",type(string1))
 
#converting the string into list of strings
list1=list(string1.split())
print("Converted string to list : ",list1)
 
#typecasting the individual elements of the string list into integer using the map() method
list2=list(map(int,list1))
print("List of integers : ",list2)

参考:
[1] https://www.askpython.com/python/string/convert-string-to-list-in-python

    本栏目推荐文章
  • AT_arc125_c [ARC125C] LIS to Original Sequence 题解
  • 安装npm install报错npm ERR! code ETIMEDOUT npm ERR! errno ETIMEDOUT npm ERR! network request to https://registry.npmjs.org/webpack-subresource-integrity failed, reason
  • python经典有序序列的list列表推导式
  • vscode错误:Unable to connect to VS Code server: Error in request.
  • Modelsim add to schemetic报错及解决
  • js string转html节点
  • fish和pacman:“error: Unable to read input file: 是一个目录”报错的处理
  • 初中英语优秀范文100篇-056I have the courage to accept the challenge-我有勇气接受挑战
  • day4: BigDecimal类, Arrays类, 包装类, String类 , Collection+迭代器,增强for
  • mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; ERROR 1410 (42000): You are not allowed to create a user with GRANT
版权声明:本网站为非赢利性站点,本网站所有内容均来源于互联网相关站点自动搜索采集信息,相关链接已经注明来源。
联系我们