免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2700 | 回复: 2

wx文本输入输出解决问题 [复制链接]

论坛徽章:
0
发表于 2008-06-01 15:50 |显示全部楼层
在wxpython  里面默认的框提取出来的都是字符串模式的吧?
        a=wx.FindWindowById(wxID_FRAME1TEXTCTRL1,self).GetValue()
        b=wx.FindWindowById(wxID_FRAME1TEXTCTRL2,self).GetValue()
        c=wx.FindWindowById(wxID_FRAME1TEXTCTRL3,self).GetValue()
        d=wx.FindWindowById(wxID_FRAME1TEXTCTRL4,self).GetValue()
        e=wx.FindWindowById(wxID_FRAME1TEXTCTRL5,self).GetValue()
        h1=string.atoi(a)
        h2=string.atoi(b)
        h4=string.atoi(d)
        h3=c.split()
        h6=map(float,h3)
        h5=e.split()
        h7=map(float,h5)

我这段代码运行老是显示有错.
提示h1=string.atoi(a)这行有错..我前面也导入string模块了....
帮我看看错哪儿了...现在我一个头两个大了.

论坛徽章:
0
发表于 2008-06-01 16:09 |显示全部楼层

错误提示如下:

File "C:\Documents and Settings\figo\JXCollage\JX.py", line 92, in OnButton1Button
    h4=string.atoi(d)
  File "D:\Python25\lib\string.py", line 401, in atoi
    return _int(s, base)
ValueError: invalid literal for int() with base 10: '0.5'
Traceback (most recent call last):

论坛徽章:
0
发表于 2008-06-01 16:12 |显示全部楼层

回复 #1 on1forever 的帖子

是因为输入是小数float,引起的错误......
应该用 string.atof
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP