V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
yellowtail
V2EX  ›  Python

语句单独可以运行,为啥在函数里报错了,景深崩溃了

  •  
  •   yellowtail · 2020-09-16 17:05:33 +08:00 · 738 次点击
    这是一个创建于 1318 天前的主题,其中的信息可能已经有所发展或是发生改变。

    368 df_tst['fee_total'] =df_tst.fee.cumsum()

    369 ###变量名

    --> 370 excel_name = '\'+str(i[:-4])+'.xls'

    371     df_tst.to_excel('C:\\Users\\l\\Desktop\\data\\'+ str(i[:-4]) + excel_name)
    
    372 
    

    TypeError: 'int' object is not subscriptable

    yellowtail
        1
    yellowtail  
    OP
       2020-09-16 17:26:41 +08:00
    在函数运行过程中 i 被替换了,应该仔细读报错说明的。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2798 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 03:55 · PVG 11:55 · LAX 20:55 · JFK 23:55
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.